1. Building a project with Maven
Problem with 2.SpringMVC absolute path
The first thing to be clear, in HTML, the resource file also has its own URL, that is, the href is the absolute path support. The following code:
<link href= "<%=request.getcontextpath ()%>/assets/css/bootstrap.min.css" rel= "stylesheet" type= "Text/css" >
When opened with a browser
<link href= "/exceptionmanagesystem/assets/css/bootstrap.min.css" rel= "stylesheet" type= "Text/css" >
In addition, you can also write this (here is to write the definition of the path variable, it is not recommended to write this)
<link rel= "apple-touch-icon-precomposed" sizes= "144x144" href= "<%=request.getscheme () +"://"+ Request.getservername () + ":" +request.getserverport () + Request.getcontextpath ()%>/assets/ico/ Kingadmin-favicon144x144.png ">
When opened with a browser, it is with IP address + port
<link rel= "apple-touch-icon-precomposed" sizes= "144x144" href= "http://localhost:8080/ExceptionManageSystem/ Assets/ico/kingadmin-favicon144x144.png ">
3. Issues where resource files cannot be displayed
In Springmvc, there are some configurations to be aware of, such as:
Web. XML code Fragment 1:
<filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/</ Url-pattern></filter-mapping>
Web. XML code Fragment 2:
<servlet-mapping> <servlet-name>springMVC</servlet-name> <url-pattern>/</ Url-pattern> </servlet-mapping>
Spring configuration file Code Snippet 3: (Configure static resources, directly mapped to the corresponding folder, not handled by Dispatcherservlet, 3.04 new features, need to reset spring-mvc-3.0.xsd)
<mvc:resources mapping= "/img/**" location= "/img/"/>
If one of the above 3 types is improperly configured, it will cause the resource file to not be displayed
4. Problems with absolute resource path unreachable in CSS style (inexplicable problem, record only)
In the project that I am writing now has CSS to use the resource file under Other folder (can display normally on Firefox, but it is not shown on chrom), for example:
[Java web–3a]–spring MVC Development Considerations