One, El expression it is just an expression in a JSP, not a development language. Basic syntax: ${el expression}1, gets the data El expression gets the object if it is null, the page does not display data. Therefore, there is never a null pointer exception p.name in the El expression: calling the GetName method with the name P object in the domain, the dot operator is used to get the value of the property. Operator: the [] operator: the. operator can do, [] can do it. [] can do,. Not necessarily able to do. For example, the advantage of ${p.name}===${p[' name ']}==${p[' name ']}[] operator is that you can take something that does not conform to the Java naming specification. 2. Mathematical logic operation: empty operator: Returns true if the object being judged is null or an empty string. For collections, even if the collection object itself is not NULL, there is no element and returns TRUE. An EL expression does not support string join operations. 3. Get the built-in object of JSP (11 large El Built-in object): Difficult, do not mix with JSP's built-in object and scope name 11 large El implicit objects, one of which is a representation of its own object, The rest are representations of the map structure El built-in Object name Java type Note PageContextjavax.servlet.jsp.PageContext is identical to the built-in object in the JSP the remaining is represented by the Map collection PageScopejava.util.Map represents p Agecontext page Range field that MAPREQUESTSCOPEJAVA.UTIL.MAP represents the ServletRequest request scope field that MAPSESSIONSCOPEJAVA.UTIL.MAP represents the HttpSession session range domain map. APPLICATIONSCOPEJAVA.UTIL.MAP represents the ServletContext application scope field that MAPPARAMJAVA.UTIL.MAP represents the request parameters. Key: The name of the request parameter. Value: The values of the request parameter, which is a string. The PARAMVALUESJAVA.UTIL.MAP represents the request parameters. Key: The name of the request parameter. Value: The values of the request parameter, which is an array of strings. The HEADERJAVA.UTIL.MAP represents the request message header. Key: Header name. Value: The header value, which is a string. The HEADERVALUESJAVA.UTIL.MAP represents the request message header. Key: Header name. Value: The header value, which is an array of strings. COOKIEJAVA.UTIL.MAP represents a map of the cookie submitted by the client. The name of the Key:cookie.The Value:cookie object itself INITPARAMJAVA.UTIL.MAP represents the global initialization parameter (Context-param in Web. xml). Key: Parameter name. Value: Parameter value 4, call the Normal class static method (El function) to write steps (custom El function Writing step is the custom label writing steps): A, write a common Java class, provide a static method public class Functiondemo {public static string toUpperCase (String str) {return str.touppercase ();}} B. Create an XML file with an extension named TLD (taglib definition) in the Web-inf directory of the Javaweb application (refer to the example in Tomcat). The contents are as follows: <?xml version= "1.0" encoding= "UTF-8"? ><taglib xmlns= "Http://java.sun.com/xml/ns/j2ee" xmlns:xsi= " Http://www.w3.org/2001/XMLSchema-instance "xsi:schemalocation=" HTTP://JAVA.SUN.COM/XML/NS/J2EE/http Java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd "version=" 2.0 "><tlib-version>1.0</tlib-version ><short-name>myfn</short-name><uri>http://www.jxn.cn/myfn</uri><function>< !--Defining a function--><name>touppercase</name><function-class>cn.jxn.el.functiondemo</ Function-class><function-signature>java.lang.string touppercase (java.lang.String) </ Function-signature></function></taglib>c, (optional step) if the TLD file is placed in the Web-inf directory. Informs the application that the TLD file corresponds to the URI in the TLD. Modify Web. XML to add the following content:<jsp-config><taglib><taglib-uri>http://www.jxn.cn/myfn</taglib-uri> <taglib-location>/WEB-INF/myfn.tld</taglib-location></taglib> </jsp-config>d, Use the TAGLIB directive in JSP to introduce a custom El function library <%@ taglib uri= "Http://www.jxn.cn/myfn" prefix= "Myfn"%> ${myfn:touppercase (p)} II, The core tag library in Jstljstl (replace Java Script in JSP) imports Jstl's required jar package: Standard.jar jstl.jarc:if: Determines if true, and if true, the body content of the tag is displayed. Properties: Test: Required. The requirement must be Boolean. Support Expression (El or Java expression) var: the variable that holds the result of the test operation scope: The scope of the saved domain. The default is Pagec:foreach traversal: array, List, Set, Map properties: Items: The target object to traverse. Support expression var: variable name. Points to an element in the currently traversed collection begin: Index (inclusive) End: End index (including) step: step. The default is 1varStatus: Takes a name and references an object. The object has the following methods: Int GetIndex (): The index number of the current record. Starting from 0 int GetCount (): The order of the current record. Starting from 1 Boolean isFirst (): Whether the first record is Boolean islast (): Is the last record
EL, JSTL