Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法调用我的Formparam webservice并获取HTTP 404错误_Java_Eclipse_Web Services_Weblogic - Fatal编程技术网

Java 无法调用我的Formparam webservice并获取HTTP 404错误

Java 无法调用我的Formparam webservice并获取HTTP 404错误,java,eclipse,web-services,weblogic,Java,Eclipse,Web Services,Weblogic,我编写了一个FormParamWebService,能够发布webservice,并在调用相应的HTML时得到HTTP404错误 以下是我的Web服务、HTML和Web.xml代码 网络服务: @Path("/UserService") public class UserWS { @POST @Path("add") @Produces(MediaType.TEXT_PLAIN) public String addUserInfo(@

我编写了一个FormParamWebService,能够发布webservice,并在调用相应的HTML时得到HTTP404错误

以下是我的Web服务、HTML和Web.xml代码

网络服务:

  @Path("/UserService")
    public class UserWS {
    @POST
       @Path("add")
       @Produces(MediaType.TEXT_PLAIN)
       public String addUserInfo(@FormParam("name") String name,
                                 @FormParam("age") int age )
       {
           return "You sent me two userids using Form param annotation ----> " + name                                       + " and " + age;
       }
   }
HTML:


在此处插入标题
向RESTfulWeb服务(JAX-RS)发送表单参数

你在html中的动作引用没有正确关闭。Thanq,我没有注意到这一点,并且花了将近一天的时间来跟踪这个问题。现在它运行良好。
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <h1> Sending Form Parameters to Restful Web service (JAX-RS)</h1>
    <form action = http://localhost:7001/UserWS/rest/UserService/add" method="post">
        <p>
            User's Name: <input type="text" name="name" />
        </p>
        <p>
            User's Age: <input type="text" name="age" />
        </p>
        <input type="submit" value="Add User info" />
    </form>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
id="WebApp_ID" version="3.0">
    <display-name>UserWS</display-name>

    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>

    <servlet>
        <servlet-name>UserWS</servlet-name>
        <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>com.sun.jersey.config.property.packages</param-name>
            <param-value>learning.webservice.users</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>UserWS</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>

</web-app>