JSP expressions and LE



## JSP:
    1. Instruction
        * Function: Used configuration JSP page, the resource file import
        * format:
            <% @ directive name attribute name attribute value = 1 1 = Attribute Name Attribute Value 2 2 ...%>
        * Classification:
            1 . page: configure JSP page
                * contentType: equivalent to response.setContentType ()
                    1. set the response body mime type and character set
                    2. set the current encoding jsp page (only advanced IDE to take effect, if a low-level tool , you need to set the character set property pageEncoding current page)
                * Import: guide package
                * errorPage: exception occurs after the current page will automatically jump to a specific error page
                * isErrorPage: identify the current is whether the error page.
                    * True: yes, you can use the built-in object Exception
                    * false: no. Defaults. Can not use the built-in object Exception


            2. the include: the page contains. Import page resource file
                * <% = @ The include File "top.jsp"%>
            3. taglib: introducing resources
                * <% @ taglib prefix = " c" uri = "http://java.sun.com/jsp/jstl/core"% >
                    * prefix: prefix customized
    2 Notes:
        1. html NOTE:
            <- ->:! html code fragment only comment
        2. JSP NOTE: recommended
            <% - -%>: can annotate All


    3 built-in objects
        * does not need to be created in the jsp page, the objects used directly
        * a total of 9:
                variable name real effect type
            * pageContext pageContext current page to share data, you can also get eight other built-in objects
            * request HttpServletRequest request once more access to resources (forward)
            * Among the plurality of session requests session HttpSession a
            * file application for all users to share data among ServletContext
            * response HttpServletResponse response object
            * page Object current page (the Servlet) For the this
            * the JspWriter OUT output target, the output data to the page
            * config ServletConfig Servlet of configuration object
            * exception Throwable exception object

    


## MVC: development mode    
    1. jsp history of the evolution
        1. early only servlet, can only use the response output tag data, very troublesome
        2. Later, jsp, simplifies the development of Servlet, jsp if overused, in the jsp-write a lot of java code, write html table, makes it difficult to maintain, difficult division of labor
        3. Later, web development java, learn mvc development model, making the design process more rationality

    2. MVC:
        1. M: model, model. The JavaBean
            * accomplish specific business operations, such as: a database query, encapsulate the object
        2. V: View, View. JSP
            * Display data
        3. C: Controller, Controller. Servlet
            * get the user's input
            * call model
            * to view the data on display


        * advantages and disadvantages:
            1. Advantages:
                1 low coupling, easy maintenance, it can be beneficial division of labor
                2. high reusability

            2. Disadvantages:
                1. making project structure is complicated, high for developers claim





## EL expression
    1. concept: expression language expression language
    2. role: replace and simplify the jsp page code written in java
    3. syntax: $ {expression}
    4. Note:
        * The default JSP support el expressions. To ignore el expression
            1. Set the jsp page directive: isELIgnored = "true" ignore all the current expressions el jsp pages
            2 \ $ {} expression: ignore the current el this expression


    5.:
        1 The arithmetic:
            * operator:
                1. arithmetic operators: + - * / (div)% (MOD)
                2. comparison operators:> <> = <= = ==!
                3. The logical operators: && (and) ! || (or) (Not)
                4. air operator: empty
                    * function: means for determining a string, set, or whether the object is null array length whether 0
                    * $ List} {empty: determining a string, set, whether the object is null or an array of length 0
                    * not empty STR $ {}: Analyzing string represents the set, if the object is not null and the array length> 0
        2. Get the value
            1. el expression can only be obtained from a subject field value
            2. syntax:
                1. The key name domain name $ {.}: Gets the value of the specified key from the specified domain
                    * domain names:
                        1. pageScope -> the pageContext
                        2. the requestScope -> Request
                        3. the sessionScope -> the session
                        4. applicationScope - > file application (the ServletContext)
                    * example: in the request is stored domain name = Joe Smith
                    * Get: requestScope.name} {$

                2. $ {name} key: indicates sequentially from the smallest to find whether a domain corresponding to the key value until you find it.

                
                
                3. Get Object, List collection, a collection of values Map
                    1. Object: $ {domain name key name attribute names..}
                        * Will go getter method calls the object's essence

                    2. List the set: $ {domain name keys [ index]}

                    3. a set of the Map:
                        * $ {Domain name keys .key name.}
                        * {$ Name domain name key [ "key name"].}


        3. implicit objects:
            * EL expression in 11 of implicit objects
            * pageContext:
                * get jsp eight other built-in objects
                    * $ {pageContext.request.contextPath}: dynamic Gets the virtual directory
                    
    
## JSTL
    1. concept: JavaServer Pages tag library JSP standard tag library
        * is open source and free jsp tag <tag> provided by the Apache organization

    2. role: to simplify the code and replace the java jsp pages        

    3. step:
        1. import jstl relevant jar package
        2. introduction tag library: taglib directive: <% @ taglib%>
        3. tag
    
    4. common JSTL tags
        1. if: the equivalent of java code if statements
            1. attribute:
                * the Test attribute must accept boolean expression
                    * If the expression is true, if the content of the tag body is displayed, if false, the contents of the tag body does not display
                    the * Generally, Test property value used in conjunction with the expression el
                2. Note:
                    * C: IF tag does else case, where else you want, you can define a c: if tags
        2. choose: java code corresponding to the switch statement
            1. statement labels corresponding to choose switch statement
            2. Analyzing the equivalent of using a when labels do case
            3. use otherwise do otherwise label statement is equivalent to default

        3. foreach: the equivalent of java code for statements

JS
## three-tier architecture: the software design architecture
    1. interface layer (presentation layer): the user interface was looking. The user can interact through the interface component and the server
    2. business logic: the business logic.
    3. Data Access Layer: operating a data storage file.

Guess you like

Origin www.cnblogs.com/liyado/p/10977659.html
jsp