我使用Spring框架在我的项目,Spring:不接受mvc下的POST请求:资源?如何解决
这里是我的web.xml的一部分:
<servlet>
<servlet-name>SpringMvcServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/servlet-context.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SpringMvcServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>httpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>httpMethodFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<error-page>
<error-code>404</error-code>
<location>/system/404.html</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/system/500.html</location>
</error-page>
和配置:
<mvc:resources mapping="/system/**" location="/WEB-INF/pages/system/" />
不过,我觉得这么多错误在我的日志中,一些这样的请求:
- POST /index.php
- POST /notexists.html
他们不是存在于我的服务器,所以会叫“/system/404.html”,但MVC:资源不接受POST方法,所以它会返回500错误。
如何解决这个问题?或者变通?
感谢
谢谢,我会稍后再试。我不是使用“POST”,而是一些scaner或机器人POST这些请求,我只是认为返回正常404更好,不会返回500错误。 – 2013-03-23 16:44:43
太棒了,它的作品! – 2013-03-23 16:57:39