2015-04-17 1 views
1

Это мой web.xml.I получил шаблон url как rest.iam, создав веб-сервис, используя jersey.but, во время работы в tomcat 6. Я получаю ошибку 404.Url pattern не работает с localhost url (jersey without maven)

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> 

Моя веб-страница Внутри этой фотографии мы можем видеть, что это просто callig отдых withlocalhost urland он получает 404 исключение.

enter image description here

Authentication.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.... 
+1

Я едва вижу URL-адрес на скриншоте. Можете ли вы ввести его за его пределами? – Claudio

+0

Не видя своего URL-адреса, вы уверены, что tomcat не использует контекст для запуска вашего приложения. Попробуйте ввести http: // localhost: 8080/[your_app_context_probably_your_war_name]/rest/... ' – Claudio

+0

http: // localhost: 9090/Snapshothealthapp1/rest this is my url.Upto" http: // localhost: 9090/Snapshothealthapp1/«Я получаю веб-страницу tomcat правильно. Но добавление остатка не работает ... – Miller

ответ

0

resloved вопрос, добавив следующий фрагмент кода в моей программе

return Response.status(201).entity(result).build(); 

и перепроверить установленные банки, как указано здесь

Jersey REST Web Service, Tomcat, Eclipse and 404's