Sitemesh3 POST失败
问题描述:
转播SpringMVC 3 405 - Request method 'POST' not supportedSitemesh3 POST失败
HTML
<form action="testPost" method="post">
<input type="submit" value="Submit" />
</form>
行动(用SpringMVC)
@RequestMapping(value="testPost", method = RequestMethod.POST)
public String testPost(){
return "shared/post";
}
加入sitemesh3过滤器之前,该提交其 '后' 的方法完全执行行动,
但一旦加sitemesh3过滤器,如果改变了HTML和行动都搞定了,还完美地工作,但如果我更改为POST,被调用的行动,但返回“405 - 请求方法‘POST’不支持”
所以我认为sitemesh3在对客户端的操作响应时发生了改变。我回顾了sitemesh3的源代码,但没有发现任何有价值的东西。
任何人都可以提供帮助吗?提前致谢。
答
我不知道这是有关您的设置,但我有同样的错误(不支持405-POST)
起初,我以为是的sitemesh相关。然而,当我在我的案例中进一步研究它时,这是因为我使用了<mvc:resources /
>来为装饰器提供静态映射。
是<mvc:resources />
这是不接受的装饰文件后请求作为的sitemesh试图用POST请求来访问它。
我改变了我的修饰器文件的映射,以确保它是静态的并响应POST和GET请求。更多详细的Spring: not accept POST request under mvc:resources? how to fix that
我使用的代码
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
<map>
<entry key="/DecTest/**" value="myResourceHandler" />
</map>
</property>
<property name="order" value="100000" />
</bean>
<bean id="myResourceHandler" name="myResourceHandler"
class="org.springframework.web.servlet.resource.ResourceHttpRequestHandler">
<property name="locations" value="/DecTest/" />
<property name="supportedMethods">
<list>
<value>GET</value>
<value>HEAD</value>
<value>POST</value>
</list>
</property>
<!-- cacheSeconds: maybe you should set it to zero because of the posts-->
</bean>