Today encountered a problem is, in the JSP introduced CSS, JS, the state of the request is 200, but the CSS, JS content is empty.
This is because the servlet has a url-pattern, the CSS, JS path as a servlet processing
The Url-pattern has 5 configuration modes:
(1)/xxx: Exactly match the path of the/xxx
(2)/xxx/*: matches the path beginning with/xxx, the request must contain XXX.
(3)/*: Match/down all paths, request can enter action or controller, but forward JSP is intercepted again, cannot access JSP interface.
(4). XX: Matches the path ending with XX, all requests must end with. XX, but will not affect access to static files.
(5)/: Default mode, paths that are not matched will be mapped to the sting servlet, and static files such as Jpg,js,css will also be intercepted and inaccessible.
Workaround, add the following configuration to Web. xml:
<!--static Resources-- <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.css</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.gif</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.jpg</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.js</url-pattern> </servlet-mapping>
JSP file cannot load CSS, JS problem