我使用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