js| Code
In general, it is a bad habit to write hard code in a program, such as: this.state= "01"; The usual practice is to write a class (interface) to hold the constants
public interface Systemconstant
{
String STATE_WTJ = "01";
}
And then you can write that in the program.
THIS.STATE=SYSTEMCONSTANT.STATE_WTJ;
In a Java program, you can avoid hard coding. But what about the JSP? Of course, if the JSP allows the use of scriplet, of course, can also directly use the constant, but now JSP generally do not allow the appearance of <%%> such code, such as in the Jstl how to do?
<c:if test=${state== '}> '
</c:if>
So there's a hard code like ' 01 '. Just saw the Appfuse solution, feel very good.
First write a jsptag, see Org.appfuse.webapp.taglib.ConstantsTag class in detail.
And then use this tag in the JSP.
<appfuse:constants scope= "Request"/>
In this way, Jstl can be written in this way:
<c:if test=${state==state_wtj}>