I have one normal servlet and one jersey specific REST related servlet i.e.ServletContainer configured in web.xml. Case 1 - Url pattern for normal servlet is "/login" Url pattern for other REST servlet is "/" In this case all request will got REST servlet. Request for login also goes开发者_JAVA技巧 to tht Servlet only. Case 2 - If Url pattern for REST servlet changed to "/rest/ " (which root path of my test resource class) And Url pattern for normal servlet as it was "/login" Only normal request for /login works, but any REST requests doesn't work.
Can anyone help me in this??
My best guess given what you've told us (I'm assuming you're running two different webapps):
Set contexts in your tomcat configuration server.xml
<Context path="" docBase="/yourworkspace/project-webapp/docs/" ... />
<Context path="/rest" docBase="/yourworkspace/project-rest/docs/" ... />
Application Mapping
In rest-web.xml (your jersey web application)
<servlet-mapping>
<servlet-name>project-rest</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
In jsp-web.xml (your jsp web application)
<servlet-mapping>
<servlet-name>project-webapp</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
In your Jersey application, your URL mapping should start on /
Example:
@Path("/car")
@Named("carResource")
public interface CarResource {
@GET
@Path("{carId}")
@Consumes("text/plain")
@Produces("application/xml")
Car getCar(@PathParam("carId") Long carId);
should handle GET http://domain.org/rest/car/42
requests.
What do you want to achieve ? In case 2 try to change it to this /rest/*.
精彩评论