EL (Expression Language)
<%
User user= (user) Session.getattribute ("User");
Dept dept=user.getdept ();
String Departname=dept.getdname ();
%>
EL:
${sessionscope.user.dept.departname}
=${sessionscope.user.dept["Departname"]}//. Same as [], but [] can be set as a variable, convenient for dynamic value, and for the inclusion of "-" these non-alphanumeric symbols, you must use [], for example: ${user[" D-name "]} correct, ${user.d-name} error
El variable has query order: page>request>session>application, no return null found
Jsp:el:
Page:pagescope;request:requestscope;session:sessionscope;application:applicationscope
JSP standard Tag Library Jstl (part of JSP standard tag Library,java EE 5.0)
Use must import tag library in JSP page (Core library "/core" prefix= "C", and function library "/functions" prefix= "FN")
<%@ taglib uri= "Http://java.sun.com/jsp/jstl/core" prefix= "C"%>
<c:foreach var= "City" items= "${citylist}" >//c: is a prefix, foreach-loop iterates through the collection, Jstl is not in <%%>
${city}<br/>
</c:forEach>
List Number: ${fn:length (citylist)}
Core:
<c:out value=${city}>
<c:set target= "${citylist}" property= "CityName" value= "Guangzhou" >//CityList Assignment "CityName" to Guangzhou objects
${<fn:trim ("ab C")}d = "AB CD"
Java Learning 06 (first time)-JSP and Servlet