Recently done projects, complete the task assigned by the project manager, started the Java Web, but encountered many problems in the development process, but I have the most headaches or import external CSS has been ineffective, plagued for a long time to find out why.
Path issues
CSS or JS import failure is the most likely reason is the path error, here I give my Site directory structure, you can refer to.
To import CSS code:
<link rel= "stylesheet" type= "Text/css" href= "Css/login.css" >
Remember that the JSP head needs to set a relative path:
<%
String Path = Request.getcontextpath ();
String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/";
%>
Set the filter
I just set up a login filter to cause CSS and JS invalidation. The solution is simple, set the request path that the filter intercepts (filter associated URL style) to the appropriate file, for example, I filter the JSP file, so my XML part is configured as follows:
<filter-mapping>
<filter-name>login</filter-name>
<url-pattern>/.jsp</ Url-pattern>
</filter-mapping>
Thank you for reading, I hope to help you, thank you for your support for this site!