我正在开发一个同时使用Spring Framework和RESTEasy的webapp。该应用程序已配置为发送REST请求一段时间,但我最近也将其设置为接收REST请求。我正确配置了我的web.xml,该应用已经收到并处理了REST请求。
这是一个web.xml片段,详细介绍了REST设置:
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
<listener>
<listener-class>
org.jboss.resteasy.plugins.spring.SpringContextLoaderListener
</listener-class>
</listener>
...
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/AutomatedProcessing/rest/*</url-pattern>
</servlet-mapping>
但是,当我在浏览器中浏览应用程序时,我会在日志中看到这些异常:
org.jboss.resteasy.springmvc.ResteasyHandlerMapping - Resource Not Found: Could not find resource for relative :
org.jboss.resteasy.spi.NoResourceFoundFailure: Could not find resource for relative : /AccountManagement/login.do of full path: https://dev.produceredge.com:7002/AccountManagement/login.do
在我看来,REST突然试图处理所有请求,不仅仅是与/ AutomatedProcessing / rest / * URL模式匹配的请求。 我没有找到关于 NoResourceFoundFailure 异常的详细信息,或者为什么REST会尝试处理其指定的URL模式之外的请求。这个例外对用户来说并不致命,但我认为这可能会破坏我不知道的事情。此外,日志中的例外情况永远不会有趣。我非常感谢对此例外的任何见解!
答案 0 :(得分:1)
答案来自订购问题。
我在config.xml文件中设置了另一个UrlHandlerMapping:
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="interceptors">
<list>
<ref bean="openPersistenceManagerInView"/>
</list>
</property>
<property name="mappings">
<value>
**/AccountManagement/login.do=flowController
**/AccountManagement/createAccount.do=flowController
**/AccountManagement/manageAccount.do=flowController
</value>
</property>
<property name="alwaysUseFullPath" value="true"/>
</bean>
此映射没有“order”属性,这意味着订单设置为默认值。 处理RESTEasy资源映射的ResteasyHandlerMapping可以在JBoss包含的sprincmvc-resteasy.xml文件中找到。此映射也没有“order”属性。 这导致两个映射具有相同的排序优先级,并且由于RESTEasy映射首先出现在XML中,因此它尝试处理所有请求。
解决方案:将此属性添加到您的默认网址映射器:
<property name="order" value="0"/>