因为springboot默认只支持GET和HEAD两种请求方式
可以在spring配置文件添加类似如下配置试试(locations可以根据需要配置):
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="urlMap"> <map> <entry key="/**" value-ref="myResourceHandler" /> </map> </property> <property name="order" value="100000" /> </bean> <bean id="myResourceHandler" class="org.springframework.web.servlet.resource.ResourceHttpRequestHandler"> <property name="locations"> <list> <value>classpath:/META-INF/resources/</value> <value>classpath:/resources/</value> <value>classpath:/static/</value> <value>classpath:/public/</value> <value>/</value> </list> </property> <property name="supportedMethods"> <list> <value>GET</value> <value>HEAD</value> <value>POST</value> </list> </property> </bean>
也可以参考这篇博文,讲述比较详细:https://blog.csdn.net/w47_csdn/article/details/80090637