ssm cannot access static css resource problem solution (try this?)

ssm cannot access static css resource problem solution (try this?)

In the web.xml configuration file, I added such a sentence, and then it always caused resource access 404

<servlet>
	<servlet-name>springDispatcherServlet</servlet-name>
	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
	<init-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:applicationContext.xml</param-value>
	</init-param>
	<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
		<servlet-name>springDispatcherServlet</servlet-name>
		<url-pattern>/</url-pattern>
</servlet-mapping>

According to the information on the Internet, it is necessary to write the springmvc configuration file. To add such a paragraph, you need to specify the absolute path of the server resource and the resource type
location : for the resource path
mapping : for the file type under the resource path

<mvc:annotation-driven />
	<mvc:resources location="/static/bootstrap-3.3.7-dist/fonts/" mapping="/static/bootstrap-3.3.7-dist/fonts/**"></mvc:resources>
	<mvc:resources location="/static/bootstrap-3.3.7-dist/css/" mapping="/static/bootstrap-3.3.7-dist/css/**"></mvc:resources>
	<mvc:resources location="/static/bootstrap-3.3.7-dist/js/" mapping="/static/bootstrap-3.3.7-dist/js/**"></mvc:resources>
<mvc:default-servlet-handler />

But in fact, I still access 404, and then I found that I only need to remove this paragraph to access the resource file

<servlet-mapping>
		<servlet-name>springDispatcherServlet</servlet-name>
		<url-pattern>/</url-pattern>
</servlet-mapping>

Maybe just turn off the interceptor?

,,,,,,
come to a big answer?

Guess you like

Origin blog.csdn.net/sorry_my_life/article/details/107350199