Summary of methods for jstl/el tags in JSP pages that refer to the Java background static statics field

Source: Internet
Author: User
Tags static class

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.