我需要在我的resteasy项目中有多个前缀。为此,我在中定义了多个servlet,如下所示 web.xml
.
<servlet>
<servlet-name>resteasy-servlet1</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
<init-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/rest1</param-value>
</init-param>
<init-param>
<param-name>resteasy.resources</param-name>
<param-value>com.test.rs.TokenGenerator</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>resteasy-servlet2</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
<init-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/rest2</param-value>
</init-param>
<init-param>
<param-name>resteasy.resources</param-name>
<param-value>com.test.rs.ResourceProvider</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>resteasy-servlet1</servlet-name>
<url-pattern>/rest1/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>resteasy-servlet2</servlet-name>
<url-pattern>/rest2/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>AuthFilter</filter-name>
<filter-class>com.test.rs.filter.AuthFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AuthFilter</filter-name>
<url-pattern>/rest2/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
这个stackoverflow帖子中定义了相同的方法,但是我的项目中还没有使用它。我总是回来 404 Not Found
尝试访问以下URL时出错。有人能强调一下我在配置中遗漏了什么吗?
http://localhost:8080/rstest/rest1/token
http://localhost:8080/rstest/rest2/资源
部署的项目的web上下文根为 rstest
我们班有 @Path
注解定义如下
@Path("/token")
public class TokenGenerator {
暂无答案!
目前还没有任何答案,快来回答吧!