Recently, I 've been idle about building a development framework. I 've encountered many problems. Google is often disconnected from the Internet, so I have no choice but to build a VPN. I still like to use Google to search for technical issues. Another redz. com search engine is also very useful, and few garbage sites are found. All are digress.
For applications using frameworks, almost every page must contain some JS scripts and CSS style sheets that are required and used by the framework, in this way, I want to create a JSP page to output the HTML code that references common JS scripts and CSS style sheets. Then, you need to reference the General JS script and the JSP page of the CSS style sheet through the include tag. This ensures the uniformity of the Framework scripts and CSS style sheets referenced on all pages. To change the framework, you only need to modify this JSP file. Of course, the best way is to use custom tags to output HTML code such as JS scripts, this helps front-end developers and server developers to better handle their own work independently.
When I tried to use the include label due to path problems, the resource could not be found. At first, I thought it could not be used for output.
<JSP: Include page = "<% = PATH %>/JSP/commoncssandjs. jsp" Flush = "true"/>
After this label is used, the console displays an error message. Refresh multiple times. Sometimes the error is: attribute for %> "is not properly terminated
, Sometimes the error is: file & quot;/apps/DMS/jiaoyanke/& lt; % = PATH % & gt;/JSP/commoncssandjs. jsp & quot; not found
Later, I checked the dynamic include related articles and added my own attempts, which are summarized as follows:
1. The page attribute value of a tag can be a relative path URL or <% = expression %>, but only one of them can exist at the same time. Reference:. http://java.sun.com/products/jsp/tags/11/syntaxref1112.html
2. When the page property value is relative URL, for example:
For example, in tester. jsp
The relative path of tester is/apps/JSP/tester. JSP. then, if tester. the page attribute of the include tag in JSP is "/app2/beincluded. JSP. JSP.
When the page attribute is "app2/beshortded. jsp", the file/apps/JSP/app2/beshortded. jsp is referenced.
3. When the page property value is <% = expression %>, the path rules are the same as those above, but note that:
"<% = PATH %>", "<% = PATH %> /***. JSP "this is not acceptable, and even a space between the quotation mark and <% = %> cannot exist, that is," <% = PATH %>"
No. If there is a space between double quotation marks and <% = PATH %>, <% = PATH %> is interpreted as a string. The console will prompt that the file with the path "<% = PATH %>" cannot be found.