这是我的web.xml。我已将URL模式设置为rest.iam使用jersey建立一个Web服务。但是在tomcat 6中运行时却出现404错误。
Web.xml
<?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_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<servlet>
<servlet-name>jersey-serlvet</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>com.snapshothealthapp1.controller</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
我的网页在此图像中,我们可以看到它只是用localhost urland进行了callig rest,它正在收到404异常。
身份验证.java
import com.snapshothealthapp1.database.Dbclass;
import com.snapshothealthapp1.model.AuthenticationModel;
import com.snapshothealthapp1.model.Jsonparser;
@Path("/customers")
public class Authentication {
@GET
@Path("/get")
// @Produces("json")
public Response getRequestUrl(@PathParam("get") String msg) {
//TODO:Create a JSON(recieved from client request)
// JSONObject jsonClient = new JSONObject();
System.out.println("inside Authentication");
String JSON_DATA =
"{"
+ " \"SnapshotRequest\": ["
+ " {"
+ " \"AuthenticationType\": \"email\","
+ " \"EmailAddress\": \"[email protected]\","
+ " \"Password\" : \"12345\","
+ " \"PracticeID\" : \"null\","
+ " \"DeviceID\" : \"null\""
+ " } + ]"
+ "}";
//TODO : ADD JSON PARSER
List arr = new ArrayList();
Jsonparser jp=new Jsonparser();
arr =jp.jsonParser(JSON_DATA);
//
//
//
//
// String result=null;
// return Response.status(201).entity(result).build();
return null;
}
@POST
@Produces("text/html")
public Request getUnamePswd(){
AuthenticationModel auth=new AuthenticationModel();
String Uname="[email protected]";
String Password="Password";
String AuthTypeID="12345678";
// String Uname="username or practice_Id";
try {
auth.validateUser(Uname,Password,AuthTypeID);
} catch (NullPointerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
Can anybody helpme?Any help will be highly appreciable....
通过在程序中添加以下代码来解决该问题
return Response.status(201).entity(result).build();
然后按照此处指定的方式重新检查已安装的jar
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句