Javaweb Learning JSP Common tags, el expression operators, Jstl tag Library (6)

Source: Internet
Author: User
Tags arithmetic operators

1 , jsp commonly used tags * As long as supporting JSP files, commonly used tags can be used directly * format: JSP:XXXX * Jsp:forward,complete the forwarding of the JSP page * Page property: Forwarding Address <% request.setcharacterencoding ("UTF-8");%><jsp:forward page= "/index.jsp"> <jsp:param Value= "Zhang San" name= "UserName"/> </jsp:forward> Browse this page will jump to index.jsp page, the browser address is unchanged ${param.username} * Operating principle The JSP engine, which processes the JSP file, parses the specific tag itself and compiles it into Java code Jsp:forward-Application.getrequestdispatcher ("/forward.jsp");* Note: In a JSP page, you can start with a slash * String path= Getabsolutepathrelativetocontext (Relativeurlpath);handle yourself individually, if not/start, automatically add* Jsp:include, dynamic inclusion,merging files when executing the current Servlet * page property: included pages * principle of execution * org.apache.jasper.runtime.JspRuntimeLibrary.inc Lude * Request.getRequestDispatcher.include * Jsp:param,set parameters, use with Jsp:forward or Jsp:include * Name property: Specify the name of the parameter * Value property: Specify the value of the parameter * Jsp:usebean tag: Create class designation Class and adds this class to the scope * Class Property: Specifies the full pathname of the class * ID property: Determines the object's instance object <jsp:usebean ID= "cal" class= "Cn.itcast.domain.Calculator"></jsp:useBean> * jsp:setproperty Tag: Set the property value for the specified JavaBean object * Name property: An existing JavaBean object in the web domain        * Property Properties: Determine the properties of the JavaBean that need to be used * The Value property: determines the specific contents of the setting * param property: Gets the contents of the specified parameter * Note: When the content is null, no value will be assigned <jsp:setproperty Property= "*" Name= "cal" Param= ""/> Get all cal values param to get the value of a parameter, such as Get <input type= "text" name= "Firstnum"/&GT;, you can write <jsp:setproperty property= "*" Name= "cal" param= "Firstnum"/> If the value of Param and property is the same, you can omit the <jsp:setproperty property= "Firstnum" Name= "cal" value= "1"/> The Firstnum property of the Cal object is set to a value of 12 , an operator of the EL expression * performs an operation. * Gets the value of the current object's properties *[]* Write a number and get the value corresponding to the subscript * Write the attribute name, get the corresponding value * escape character: * * invalidate el expression * arithmetic operators, logical operators, relationships operator * Empty three mesh operator
${empty user} returns True or False3. Jstl Tag Library 1, the process of using the Tag Library * Guide Package (myeclipse) * In the current JSP page Header declaration reference * <%@ taglib URI= "Http://java.sun.com/jsp/jstl/core" prefix= "C"%> * taglib directive: Determine the tag library used * URI: Determine the tag library used, specific name * prefix: an alias for the current tag library * Use * <prefix:xxx or < aliases: xxx2, domain object operation * Set: the var attribute to the Web domain setting value: The name of the property: The value of the property property, the scope property: scoping * Page * Request * session * Application <c:set var= "GF" value= "Fengjie" scope= "page"></c:set> <c:set var= "GF" value= "Fengjie" scope= "Request"></c:set> <c:set var= "GF" value= "Fengjie" scope= "Session"></c:set> <c:set var= "GF" value= "Fengjie" scope= "Application"></c:set> \${GF}--${requestscope.gf}<br/> \${GF}--${requestscope.gf}& Lt;br/> \${GF}--${sessionscope.gf}<br/> \${GF}--${APPLICATIONSCOPE.GF}<BR/&G T * Remove: Delete the value of the web domain with the specified name * var property: OK Name * Note: Delete all scope contents <c:remove var= "GF"/> * out: Content output * Value: Specified content * Note: You can use el Expression * EscapeXML: whether to escape HTML-defined characters * Default value True, Escape * default: Show defaults <c:set var when current output is empty= "GF" value= "<a href= ' # ' >fengjieout</a>" scope= "page"></c:set> <c:out Value= "${gf2}" default= "No Value"></c:out>3, data manipulation * If tag: logical judgment * Test attribute: Logical value True|false * Support El expression <c:set var= "User" value= "xx"></c:set> <c:if Test= "${empty User}"> User object is null <br/> </c:if> * Choose tag: Determines a set of display results that can be selected * When label must be placed * sub-label * When tag: logical judgment * Test attribute: Fill logical value * Otherwis E Tags: handling no processing items, default items <c:choose> <c:when test= "${empty User}"> When:user null </c:when> <c:when test= "${!empty User2}"> When:user NOT NULL </c:when> <C:OTHERWISE&G T No processing items </c:otherwise> </c:choose> * foreach tag: Iterate,each piece of information will be displayed in the label Body * Items Property: Determine traversed Object * Support El expression or * Begin property: * End Properties: * Total * var attribute: Determine traversal variable * Step property: Step i+=2 i++--I+=1<c:foreach Items= "${headervalues}" var= "Hvs"> \${hvs}--${hvs.key}: <c:foreach items= "${hvs.value}" var= "H"> ${h} * * * * </c:forEach> <br/> </c:for Each> *url tag: Generates the current response relative to the Web site's completion Path * Value property: The location of the specified page * Note: Content if/start, relative to the current Web project &L T;c:url var= "Demourl" value= "/demo1/calculator.jsp"></c:url>

Javaweb Learning JSP Common tags, el expression operators, Jstl tag Library (6)

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.