before the DRP project in contact with ${pagecontext.request.contextpath}, did not pay attention to, this time in the Java version of the University cloud Platform ITOO4.0 again meet with it, is really wuqiaobuchengshu ah. Met again, I ignored again, that is not justified it.
before we say a word, we have to simply say El expressions. an El expression
EL full name is Expressionlanguage. function is: Ø get data:
El expressions are used primarily to replace script expressions in JSP pages to retrieve Java objects and fetch data from various types of Web domains. (objects in a web domain, accessing JavaBean properties, accessing the list collection, accessing the map collection, accessing the array) Ø Perform operations:
using El expressions, you can perform some basic relational, logical, and arithmetic operations in a JSP page to complete some simple logical operations in a JSP page. ${user==null} Ø get common objects for web development
EL Expressions Define implicit objects that make it easy for web developers to get references to web-common objects and get the data from those objects. Ø Invoke Java method
El expressions allow users to develop custom El functions to invoke methods of Java classes in a JSP page through an El expression.
The main way to get data is to use the following:
get data syntax using el expression: "${identifier}"
The El expression statement, when executed, invokes the Pagecontext.findattribute method, using the identifier as the keyword, to find the corresponding object from page, request, session, application four domains, If found, returns the object and returns "" (note, not NULL, but an empty string). ${pagecontext.request.contextpath}
{PageContext.request.contextPath} is actually a type of El expression, using El to get the value of the principle of getting the data from the Get method:
pagecontext.getrequest () Gets the HttpServletRequest object, which is the first step, and the second step is to use the obtained httpservletrequest to invoke the Getcontextpath method.
The purpose is to remove the deployed application name so that regardless of deployment, the path is correct.
The advantages and disadvantages of other ways to get paths:
Http://www.cnblogs.com/langtianya/archive/2013/03/04/2942515.html
In addition, we used to use JSP script to do the output: The specific is:
<%=request.getcontextpath ()%>, which can return the name of the application to which the current page resides. Øel is better than scripting <%%>
1. El expressions are represented by ${} and can be used in all HTML and JSP tags to replace the complex Java code in the JSP page.
2. El expressions manipulate constant variables and implicit objects. The most commonly used implicit object has ${param} and ${paramvalues}. ${param} to return the value of a single string in the request parameter. ${paramvalues} Represents a set of values that return a request parameter. pagescope represents a variable of a page range. Requestscope represents a variable of the Request object. Sessionscope represents a variable within the scope of a session. Applicationscope represents a variable of the scope of the application .
3. <% @pageisELIgnored = "true"%> indicates whether the El language is disabled, true to prohibit. False indicates that the default enabled El language in. JSP2.0 is not prohibited .
4, El language can display logical expressions such as ${trueand false} result is false relational expression such as ${5>6} result is false arithmetic expressions such as ${5+5} result is
5, El in the variable search scope is: page,equest,session,application dot operator (.) and "[]" are the values that represent the get variable. The difference is [] a small extension of the variable knowledge that can show the non-part of speech
request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () +path+ "/"; This is also a very common expression in the DRP project, which is commonly used before we use ${pagecontext.request.contextpath}.
So what exactly does that mean?
seemingly difficult to understand, in fact, to get the application of the root URL, or access to address, for example, we often visit the local address of the 8080-port number, that is, http://localhost:8080;
Specific Explanation:
1, Request.getscheme () return the name of the protocol HTTP, and the following "://" spell it into a http://
2, Request.getservername () This is to get the name of your server this machine is localhost or 127.0.0.1, both represent local
3, Request.getserverport () return the port number, such as 8080 Summary
before the three a little bit of memory is not clear, summed up a moment, suddenly more clear, knowledge or Shing ah.