在SpringMVC框架中当使用post请求服务,然后请求成功转到一个静态文件,如html,htm等网页时。页面出现405 request method post not supported错误,只要在spring的配置文件中加入下面代码即可:
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
<map>
<entry key="/pages/*.html" 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="/pages/*.html" />
<property name="supportedMethods">
<list>
<value>GET</value>
<value>HEAD</value>
<value>POST</value>
</list>
</property>
</bean>