Why use this feature?
Each page in the project contains the product name, Logo, version and other information, I would like to change one, all the other changes.
Some students say that all refer to a page "" is OK, but I hope that this information can be modified through the background code, modified to save to the database and a static class, in fact, the background directly read and write the referenced page or save to the properties file (property) is also possible, I think it's better to save it in the database.
And the students said that the use of "<%=com.xunge.base.constant.PlatInfo.title%>" is good, but this is too long, not easy to remember, each page refers to this long string of things you do not feel bored?
Available methods
method One:
It is recommended that you first include this method in the page:
<% Request.setattribute ("title", Com.xunge.base.constant.PlatInfo.title); %>
It can then be used by "${title}".
Method Two:
First add to the page:
<c:set var= "title" value= "<%=com.xunge.base.constant.PlatInfo.title%>"/>
It can then be used by "${title}".
Note: There can be no spaces between the percent sign and the equal signs, otherwise it will not be parsed, such as:
Also does not produce an "HTTP Status 500-unable to compile class for Jsp:syntax error on token" = "@ expected" errors;
Method Three:
First add to the page:
<% String title = Com.xunge.base.constant.PlatInfo.title; %>
It can then be used by "${title}".
But there is a problem with this approach:
If the statement is included in multiple JSP pages that are referenced in a page, the following error occurs:
HTTP Status 500-unable to compile class for jsp:duplicate local variable title
Methods that are not available
Using the following statements directly is not a value, even if you join "<% @page import=" Com.xunge.base.constant.PlatInfo "%> also useless":
${com.xunge.base.constant.platinfo.title}
The following sentence of the semicolon and the equal sign has a space, is not resolved, is the face said.
<c:set var= "title" value= "<% =com.xunge.base.constant.platinfo.title%>"/>
Summary of methods for jstl/el tags in JSP pages that refer to the Java background static statics field