1、在web.xml中修改默认servlet为com.sun.jersey.spi.spring.container.servlet.SpringServlet
2、为了配置文件能起效,增加上下文监听和配置文件的读取。
示例web.xml
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app version="3.0" xmlns=""
- xmlns:xsi=""
- xsi:schemaLocation="
- /web-app_3_0.xsd">
- <display-name></display-name>
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>/WEB-INF/classes/spring/applicationContext.xml</param-value>
- </context-param>
- <servlet>
- <servlet-name>JAX-RS REST Servlet</servlet-name>
- <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
- <!-- The following initialization parameter is only required for
- registering Jersey managed classes. Spring-managed classes
- are automatically registered.
- -->
- <init-param>
- <param-name>com.sun.jersey.config.property.packages</param-name>
- <param-value>com.intime.ws.main</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>JAX-RS REST Servlet</servlet-name>
- <url-pattern>/api/*</url-pattern>
- </servlet-mapping>
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <welcome-file-list>
- <welcome-file>index.jsp</welcome-file>
- </welcome-file-list>
- </web-app>
阅读(2099) | 评论(0) | 转发(0) |