JSP syntax detailed

xiaoxiao2021-03-06  50

HTML Comment Displays a comment on the client.

JSP syntax

] ->

Example 1

Generate and the same data as above in the client's HTML source code:

Example 2

->

Displayed in the client's HTML source code:

Description / R

This annotation is very similar to HTML, that is, it can be seen in "View Source /".

The only difference is that you can use expressions in this comment. This expression is unclear, different from the page, you can use a variety of expressions, as long as it is legal. More please see the expression

Hidden comments

Write in the JSP program, but not send it to the customer.

JSP syntax

<% - comment -%>

example:

<% @ Page language = "java"%> a comment test </ title> </ head> <body> <h2> a test of comments </ h2> <% - this Comment will not be visible in the page source -%> </ body> </ html></p> <p>Description / R</p> <p>The characters with hidden comments marked will be ignored when JSP compiles. This comment is useful when you want to hide or annotate your JSP program. The JSP compiler does not compile the statement between <% - and -%>, which does not display in the customer's browser, and will not see in the source code.</p> <p>statement</p> <p>Declaring the legal variables and methods in the JSP program</p> <p>JSP syntax</p> <p><%! Declaration; [Declaration;] ...%></p> <p>example</p> <p><%! Int = 0;%></p> <p><%! Int A, B, C;%></p> <p><%! Circle a = new circle (2.0);%></p> <p>Description / R</p> <p>Declare that variables and methods you will be used in the JSP program. You must do this, or you will be wrong.</p> <p>You can declare multiple variables and methods in one time, as long as ";" is ending, of course, these statements are legal in Java.</p> <p>Please pay attention to some of the following rules when you declare methods or variables:</p> <p>The statement must be ";"; "Scriptlet has the same rule, but the expression is different).</p> <p>You can use the declared variables and methods that have been included in <% @ Page%>, do not need to be re-declared.</p> <p>A statement is only valid in one page. If you want each page to use some statements, it is best to write them into a separate file, then use <% @ include%> or <jsp: include> element.</p> <p>expression</p> <p>Contains an expression that conforms to JSP syntax</p> <p>JSP syntax</p> <p><% = Expression%></p> <p>example</p> <p><font color = "blue"> <% = map.size ()%> </ font> <b> <% = numguess.get ()%> </ b>.</p> <p>Description / R</p> <p>Expression elements indicate a expression that is defined in the scripting language, which is automatically converted to a string after running, and then inserted into this expression of the JSP file display. Because the value of this expression has been converted to a string, you can insert this expression in a line of text (the form and ASP is exactly the same).</p> <p>Remember the following: When you use an expression in JSP:</p> <p>You can't use a semicolon (";") as an expression of the expression. But the same expression is used in the scriptlet! View Scriptlet</p> <p>This expression element can include any active expression in Java Language Specification.</p> <p>Sometimes the expression can also be an attribute value of other JSP elements. An expression can become complicated, it may consist of one or more expressions, these expressions are from left to right.</p> <p>[/ b] scriptlet [/ b]</p> <p>Contains an effective block.</p> <p>JSP syntax</p> <p><% Code Fragment%></p> <p>example</p> <p><%</p> <p>String name = NULL;</p> <p>IF (Request.GetParameter ("name") == null) {</p> <p>%></p> <p><% @ Include file = "Error.html"%></p> <p><%</p> <p>} Else {</p> <p>Foo.setName (Request.GetParameter ("name");</p> <p>IF (foo.getname (). EqualsignoreCase ("Integra"))</p> <p>Name = "acura";</p> <p>IF (name.equalsignorecase ("acura")) {</p> <p>%></p> <p>Description / R</p> <p>A scripTlet can include multiple JSP statements, methods, variables, expressions</p> <p>Because Scriptlet, we can do the following things:</p> <p>Declare the variables or methods to be used (reference declarations).</p> <p>Write a JSP expression (reference expression).</p> <p>Use any implicit objects and any objects that use <JSP: Usebean></p> <p>Write a JSP statement (if you are using Java language, these statements must follow Java Language Specification,).</p> <p>Any text, HTML tag, JSP element must be outside Scriptlet</p> <p>When JSP receives a customer request, the scriptlet will be executed if the scriptlet has the content displayed, and the contents of these display are existing in the OUT object.</p> <p>Include instruction</p> <p>Contains a static file in the JSP while parsing the JSP statement in this file.</p> <p>JSP syntax</p> <p><% @ Include file = "relativeURL"%></p> <p>example</p> <p>INCLUDE.JSP:</p> <p><html> <head> <title> An incrude test </ title> </ head> <body bgcolor = "white"> <font color = "blue"> The current date and time all <% @ include file = "Date .jsp "%> </ font> </ body> </ html> Date.jsp:</p> <p><% @ Page import = "java.util. *"%> <% = (New java.util.date ()) .tolocalestring ()%></p> <p>Displays in the page:</p> <p>THE CURRENT DATE AND TIME ARE</p> <p>Aug 30, 1999 2:38:40</p> <p>Description / R</p> <p><% @ include%> The instruction will insert a file containing text or code when the JSP is compiled. When you use <% @ include%> instruction, this containing process is static. Static container means that this file containing files will be inserted into the JSP file. This containable file can be a JSP file, an HTML file, a text file. If included is a JSP file, the code in this file containing the JSP will be executed.</p> <p>If you just use INCLUDE to include a static file. The result of this containing files will be inserted into the JSP file. Once the included file is executed, the process of the primary JSP file will be recovered and the next line is proceed.</p> <p>This containing files can be HTML files, JSP files, text files, or just a java code, but you have to pay attention to <html>, </ html>, <body>, </ body> tag in this included file Because this will affect the same tag in the original JSP file, so sometimes it will cause errors.</p> <p>There are some <% @ include%> Directance behavior is based on special JSP compilation conditions, such as:</p> <p>This included file must be open to all customers and must be valid, or it has secure limitations.</p> <p>If this included file is changed, the JSP file containing this file will be recompiled.</p> <p>Attributes:</p> <p>FILE = "relativeurl"</p> <p>This containing file path name is generally referring to the relative path, no port, protocol, and domain name, as follows:</p> <p>"Error.jsp" "Templates / Onlinestore.html" "/ beans / calendar.jsp"</p> <p>If this path starts with "/", this path is primarily referring to the up and down relationship path of the JSP application. If the path starts with a file name or directory name, then this path is the current path of the JSP file being used.</p> <p>Page instruction</p> <p>Define global properties in the JSP file.</p> <p>JSP syntax</p> <p><% @ PAGE</p> <p>[Language = "java"]</p> <p>[Extends = "package.class"]</p> <p>[Import = "{package.class | package. *}, ..."]</p> <p>[Session = "true | false"]</p> <p>[Buffer = "none | 8kb | sizekb"] [Autoflush = "True | False"]</p> <p>[Isthreadsafe = "True | false"]</p> <p>[Info = "text"]</p> <p>[ErrorPage = "relativeURL"]</p> <p>[ContentType = "MIMETYPE [; Charset = Characterset]" | Text / HTML; Charset = ISO-8859-1 "]</p> <p>[ISerrorPage = "true | false"]</p> <p>%></p> <p>example</p> <p><% @ Page Import = "java.util. *, Java.lang. *"%></p> <p><% @ Page Buffer = "5KB" Autoflush = "false"%></p> <p><% @ Page ErrorPage = "Error.jsp"%></p> <p>Description / R</p> <p><% @ Page%> The instruction acts on the entire JSP page, and also includes static include files. But <% @ Page%> The instruction does not work to dynamically contain files, such as <JSP: Include></p> <p>You can use multiple <% @ Page%> instructions in a page, but the properties can only be used once, but there is also an exception, that is the import property. Because the Import property and the Import statement in Java are almost almost (refer to Java Language), you can use this property several times.</p> <p>Whether you put <% @ Page%> instructions in JSP files, its scope is entire JSP page. However, for the readability of the JSP program, and good program habits, it is best to put it on the top of the JSP file.</p> <p>Attributes</p> <p>Language = "java"</p> <p>Declare the type of scripting language, you can only use "java"</p> <p>Extends = "package.class"</p> <p>The full name of Java Class, which is required to add JAVA Class, but use it carefully, which limits the compiletability of JSP.</p> <p>Import = "{package.class | package. *}, ..."</p> <p>A list of Java packages that require imported, these packets act on blocks, expressions, and declarations.</p> <p>The following packages have been imported at the JSP compile, so you don't need to indicate again:</p> <p>Java.lang. *</p> <p>Javax.Servlet. *</p> <p>Javax.Servlet.jsp. *</p> <p>Javax.Servlet.http. *</p> <p>session = "True | FALSE"</p> <p>Set whether the customer needs http session. (If you have learned ASP, it should be no stranger to it) if it is True, then the session is useful.</p> <p>If it has false, then you can't use the Session object, and define the <JSP: UseBean> element of Scope = Session. Such use can cause errors.</p> <p>The default is True.</p> <p>Buffer = "None | 8KB | SIZEKB"</p> <p>The size of the buffer is used by the OUT object to handle the executionful JSP's output of the client browser. The default is 8KB</p> <p>Autoflush = "True | FALSE"</p> <p>Setup if the buffer overflows, if the value is required, if its value is defined as true (default), the output is normal, if it is set to false, if this buffer overflows, it will cause an unexpected error. If you put Buffer is set to none, then you can't set autoflush to false.istryreadsafe = "true | false"</p> <p>Set whether the JSP file can be used multithreaded. The default is True, that is, JSP can handle a request for multiple users at the same time. If set to false, a JSP can only handle a request at a time.</p> <p>INFO = "text"</p> <p>A text will be joined in JSP in executing JSP, and you can retrieve it using the servlet.getServletInfo method.</p> <p>ErrorPage = "relativeurl"</p> <p>Set the JSP file for processing an exception event.</p> <p>iSerrorPage = "True | FALSE"</p> <p>Set whether this page is an error page, if set to true, you can use the Exception object.</p> <p>ContentType = "MIMETYPE [; Charset = Characters" | "text / html; charSet = ISO-8859-1"</p> <p>Set the MIME type. The default MIME type is: Text / HTML, the default character set is ISO-8859-1.</p> <p><JSP: Forward></p> <p>Redirect an HTML file, a JSP file, or a block.</p> <p>JSP syntax</p> <p><JSP: Forward Page = {"RelativeURL" | "<% = express%>"} /></p> <p>oral</p> <p><jsp: forward page = {"relativeURL" | <% = express%> "}></p> <p><jsp: param name = "parametername"</p> <p>Value = "{parameterValue | <% = express%>}" /> </p> <p></ jsp: Forward></p> <p>example</p> <p><JSP: Forward Page = "/ servlet / login" /></p> <p><jsp: forward page = "/ servlet / login"></p> <p><jsp: param name = "username" value = "jsmith" /></p> <p></ jsp: Forward></p> <p>Description / R</p> <p><JSP: Forward> Tag Pass from a JSP file to another file with a request object containing a user request. The code below the <JSP: Forward> tag will not be executed.</p> <p>You can send parameters and values ​​to the target file, in this example, the parameters we passed are namedame, the value is Scott, if you use the <JSP: Param> tag, the target file must be a dynamic file, you can handle parameters .</p> <p>If you use a non-buffered output, be careful when using <JSP: Forward>. If you use <JSP: Forward>, the JSP file already has data, then the file execution will be wrong.</p> <p>Attributes</p> <p>Page = "{relativeURL | <% = expression%>}"</p> <p>Here is an expression or a string to explain the file or URL you will oriented. This file can be a JSP, block, or other file capable of handling the Request object (such as ASP, CGI, PHP). <JSP: Param name = "parameters" value = "{parameterValue | <% = express%>}" /> </p> <p>Send one or more parameters to a dynamic file, this file must be a dynamic file.</p> <p>If you want to pass multiple parameters, you can use multiple <JSP: param> in a JSP file. Name Specifies the parameter name, Value Specifies the parameter value.</p> <p><JSP: GetProperty></p> <p>Get the properties of the bean, used to display in the page</p> <p>JSP syntax</p> <p><jsp: getProperty name = "beaninstancename" property = "printyname" /></p> <p>example</p> <p><jsp: usebean id = "calendar" scope = "page" class = "Employee.calendar" /></p> <p><H2></p> <p>Calendar of <JSP: getProperty Name = "Calendar" Property = "UserName" /></p> <p></ h2></p> <p>Description / R</p> <p>This <JSP: getProperty> element will get the properties value of the bean and can be used or displayed in the JSP page. You must create it with <JSP: UseBean> before you use <JSP: getProperty>.</p> <p><JSP: getProperty> Elements have some restrictions:</p> <p>You can't use <JSP: getProperty> to retrieve an attribute that has been indexed</p> <p>You can use <JSP: getProperty> with the Javabeans component, but cannot be used with Enterprise Beans.</p> <p>Attributes</p> <p>Name = "beaninstancename"</p> <p>Bean's name, by <JSP: Usebean></p> <p>Property = "PropertyName"</p> <p>The attribute name of the specified bean.</p> <p>skill:</p> <p>In the JSP reference in Sun, if you use <jsp: getproperty> to retrieve the value is null, then NullPointerException will appear, and if you use the block or expression to retrieve its value, then appear on the browser NULL (empty).</p> <p><JSP: Include></p> <p>Contains a static or dynamic file.</p> <p>JSP syntax</p> <p><JSP: Include Page = "{RelativeURL | <% = Expression%>}" flush = "true" /></p> <p>oral</p> <p><JSP: Include Page = "{RelativeURL | <% = Expression%>}" flush = "true"></p> <p><jsp: param name = "parametername" value = "{parametervalue | <% = express%>}" /> </p> <p></ jsp: incrude></p> <p>Examples</p> <p><jsp: include page = "scripts / login.jsp" /> <jsp: include page = "copyright.html" /></p> <p><jsp: include page = "/ index.html" /></p> <p><jsp: include page = "scripts / login.jsp"></p> <p><jsp: param name = "username" value = "jsmith" /></p> <p></ jsp: incrude></p> <p>Description / R</p> <p><JSP: Include> Elements Allows you to include dynamic files and static, which are different from the results of the files. If the file is just a static file, this includes adding the contents of the included file to the JSP file, and if this file is dynamically, then this containing file will be executed by the JSP compiler (this is similar to the ASP )</p> <p>You can't judge a file from a file name to be dynamic or static, such as aspcn.asp may just contain some information, without having to execute. <JSP: Include> can handle these two files at the same time, so you don't need to include this file is dynamic or static.</p> <p>If this included file is dynamic, you can also pass the parameter name and parameter value with <JSP: param>.</p> <p>Attributes</p> <p>Page = "{relativeURL | <% = expression%>}"</p> <p>The parameter is a relative path, or represents a relative path expression.</p> <p>Flush = "True"</p> <p>Here you must use flush = "true", you can't use false values. The default is false</p> <p><jsp: param name = "parametername" value = "{parametervalue | <% = express%>}" /> </p> <p><JSP: Param> clause allows you to pass one or more parameters to dynamic files</p> <p>You can use multiple <JSP: param> in a page to deliver multiple parameters,</p> <p><JSP: Plugin></p> <p>Execute an applet or bean, there is a possibility to download a Java plugin for execution it.</p> <p>JSP syntax</p> <p><JSP: Plugin</p> <p>TYPE = "bean | applet"</p> <p>Code = "ClassFileName"</p> <p>CodeBase = "classfiledirectoryname"</p> <p>[Name = "instancename"]</p> <p>[Archive = "Uritoarchive, ..."]</p> <p>[Align = "bottom | TOP | MIDDLE | LEFT | Right"]</p> <p>[Height = "displaypixels"]</p> <p>[Width = "displaypixels"]</p> <p>[Hspace = "LeftrightPixels"]</p> <p>[VSpace = "Topbottompixels"]</p> <p>[Jreversion = "jreversionnumber | 1.1"]</p> <p>[Nspluginurl = "urltoplugin"]</p> <p>[IEpluginURL = "URLTOPLUGIN"]></p> <p>[<JSP: Params></p> <p>[<Jsp: param name = "parametername" value = "{parameterValue | <% = express%>}" />] </p> <p></ jsp: params>]</p> <p>[<JSP: Fallback> Text Message for User </ jsp: Fallback>]</p> <p></ jsp: plugin></p> <p>example</p> <p><JSP: Plugin Type = Applet Code = "Molecule.class" CodeBase = "/ html"></p> <p><jsp: params></p> <p><jsp: param name = "molecule" value = "molecules / benzene.mol" /></p> <p></ jsp: params></p> <p><JSP: Fallback></p> <p><p> unable to load applet </ p></p> <p></ jsp: Fallback></p> <p></ jsp: plugin></p> <p>Description / R</p> <p><JSP: Plugin> element is used to play or display an object in the browser (typical is applet and bean), and this display requires the Java plugin of the browser.</p> <p>When the JSP file is compiled, when sending to the browser, the <jsp: plugin> element will replace the "Object> or <Embed> element according to the version of the browser. Note, <Object> is used for HTML 4.0, <Embed> for HTML 3.2.</p> <p>In general, the <JSP: PLUGIN> element will specify an object is applet or bean, and the name of the Class is also specified, and there is location, and it will also specify where to download this Java plugin. details as follows:</p> <p>Attributes</p> <p>TYPE = "bean | applet"</p> <p>The type of plug-in object that will be executed, you must specify this bean or applet because this property has no default.</p> <p>Code = "ClassFileName"</p> <p>The name of the Java Class will be performed by the Java plug-in, must end with .class. This file must exist in the directory specified by the CodeBase property.</p> <p>CodeBase = "classfiledirectoryname"</p> <p>The directory (or path) of the Java Class file will be executed, if you do not provide this property, the directory of the JSP file using the <JSP: Plugin> will be used.</p> <p>Name = "instanceename"</p> <p>The name of this bean or applet instance will be called in JSP.</p> <p>Archive = "uritoarchive, ..."</p> <p>Some pathnames separated by commas, these path names are used to pre-install some of the Class to use, which increases the performance of the applet.</p> <p>Align = "bottom | TOP | Middle | Left | RIGHT"</p> <p>Graphics, objects, and applets, have the following values:</p> <p>Bottom</p> <p>TOP</p> <p>Middle</p> <p>Left</p> <p>Right</p> <p>Height = "DisplayPixels" width = "displaypixels"</p> <p>Applet or bean will display the long width value, this value is a number, the unit is pixel.</p> <p>Hspace = "Leftrightpixels" vSpace = "Topbottompixels" Applet or bean is displayed on the screen, the space you need to leave up and down, the unit is pixel.</p> <p>Jreversion = "JreversionNumber | 1.1"</p> <p>Applet or bean runs the version of Java Runtime Environment (JRE) required. The default is 1.1.</p> <p>nspluginurl = "Urltoplugin"</p> <p>Netscape Navigator users can use the download address of JRE, this value is a standard URL, such as http://www.aspcn.com/jsp</p> <p>IEPLUGINURL = "URLTOPLUGIN"</p> <p>The download address of the JRE that IE can use, this value is a standard URL, such as http://www.aspcn.com/jsp</p> <p><JSP: params> [<jsp: param name = "parameters" value = "{parameterValue | <% = express%>}" />] </ jsp: params></p> <p>You need to send parameters or parameter values ​​to Applets or Beans.</p> <p><JSP: Fallback> Text Message for User </ JSP: Fallback></p> <p>A text is used for the Java plug-in to display to the user when the plugin is booted and the Applet or Bean cannot be, then the browser will have an error message pop-up.</p> <p><JSP: SetProperty></p> <p>Set the attribute value in the bean.</p> <p>JSP syntax</p> <p><jsp: setProperty</p> <p>Name = "beaninstancename"</p> <p>{</p> <p>Property = "*" |</p> <p>Property = "PropertyName" [param = "parametername"] |</p> <p>Property = "PropertyName" Value = "{string | <% = expression%>}"</p> <p>}</p> <p>/></p> <p>example</p> <p><jsp: setproperty name = "mybean" property = "*" /></p> <p><jsp: setproperty name = "mybean" property = "username" /></p> <p><jsp: setproperty name = "mybean" property = "username" value = "steve" /></p> <p>Description / R</p> <p><JSP: SetProperty> Elements uses beans to set the setter method, set one or more attribute values ​​in the BEAN. You must use the <JSP: UseBean> to declare this bean before using this element. Because, <JSP: UseBean> and <JSP: setProperty> are associated, and the name of the Bean instance they use should also match. (That is to say, the value of Name in <jsp: setProperty> should be the same as the value of id in <jsp: usebean>)</p> <p>You can use a variety of ways to use <JSP: SetProperty> to set the property value:</p> <p>Match the attributes in the bean by the specified value input by the user by all values ​​input by the user (in the Request object in parameter storage), match the specified value input by the user.</p> <p>Use an expression when running to match the properties of the bean</p> <p>Each method of setting attribute values ​​has its specific syntax, below we will explain</p> <p>Property and its usage</p> <p>Name = "beaninstancename"</p> <p>Represents the name of the bean instance created in <JSP: UseBean>.</p> <p>Property = "*"</p> <p>Store all values ​​for the user in the JSP input to match the properties in the bean. The name of the attribute in the bean must match the parameter name in the Request object.</p> <p>The parameter values ​​transmitted from the customer to the player are generally character types, which must be converted to other types in the bean, and the type of bea property and their conversion method are listed in the table below.</p> <p>Transform strings into other types of methods. Property type</p> <p>method</p> <p>Boolean or Boolean</p> <p>Java.lang.Boolean.Valueof (String)</p> <p>Byte or byte</p> <p>Java.lang.byte.valueof (String)</p> <p>Char or Character</p> <p>Java.lang.Character.Valueof (String)</p> <p>Double or DOUBLE</p> <p>Java.lang.double.valueof (String)</p> <p>Integer or Integer</p> <p>Java.lang.integer.Valueof (String)</p> <p>Float or float</p> <p>Java.lang.float.Valueof (String)</p> <p>Long or long</p> <p>Java.lang.long.Valueof (String)</p> <p>If there is an empty value in the parameter value of the Request object, the corresponding bean property will not set any values. Similarly, if there is an attribute in the bean without the corresponding request parameter value, then this property is also not set.</p> <p>Property = "PropertyName" [param = "parametername"]</p> <p>Use a parameter value in the Request to specify an attribute value in the bean. In this syntax, Property specifies the property name of the bean, and param specifies the parameter name in the request.</p> <p>If the bean property is different from the name of the request parameter, you must specify Property and Param if they are the same name, then you just need to indicate that Property is fine.</p> <p>If the value is empty (or not initialized), the corresponding bean property is not set.</p> <p>Property = "PropertyName" Value = "{string | <% = expression%>}"</p> <p>Use the specified value to set the bean property. This value can be a string or an expression. If this string, it will be converted to the type of the bean property (see the above table). If it is an expression, then its type must be consistent with the type of attribute value to be set.</p> <p>If the parameter value is empty, the corresponding attribute value will not be set. Also, you can't use Param and Value in a <JSP: SetProperty></p> <p>skill</p> <p>If you use Property = "*", then bean's properties are not necessary to sort in the order in the HTML form.</p> <p><JSP: Usebean></p> <p>Create a bean instance and specify its name and scope.</p> <p>JSP syntax</p> <p><JSP: Usebean</p> <p>ID = "BeanInstanceName"</p> <p>Scope = "Page | Request | Session | Application" {</p> <p>Class = "package.class" |</p> <p>TYPE = "package.class" |</p> <p>Class = "package.class" type = "package.class" |</p> <p>Beanname = "{package.class | <% = expression%>}" type = "package.class"</p> <p>}</p> <p>{</p> <p>/> | |</p> <p>> Other Elements </ jsp: usebean></p> <p>}</p> <p>example</p> <p><jsp: usebean id = "cart" scope = "session" class = "session.carts" /></p> <p><jsp: setproperty name = "cart" property = "*" /></p> <p><jsp: usebean id = "checking" scope = "session" class = "bank.checking"></p> <p><jsp: setproperty name = "checking" property = "balance" value = "0.0" /></p> <p></ jsp: usebean></p> <p>Description / R</p> <p><JSP: Usebean> is used to position or sample a JavaBeans component. <JSP: Usebean> You will try to locate a bean instance if this bean does not exist, then <JSP: UseBean> is an example from a Class or template.</p> <p>For positioning or examples of beans, <JSP: UseBean> will make the following steps, the order is as follows:</p> <p>Try to locate a bean by a given name and scope.</p> <p>Reference variables for this bean object are named in the name you specify.</p> <p>If this bean is found, this reference will be stored in this variable. If you also specify a type, this bean is also set to the corresponding type.</p> <p>If this bean is not found, it will be sampled from the class you specified and this reference is stored in a new variable. If the name of this class represents a template, then this bean is sampled by java.beans.beans.instantiate.</p> <p>If <JSP: UseBean> has been sample (not locating), it has an element in <JSP: Usebean> and </ jsp: Usebean>, then the code will be executed.</p> <p><JSP: USEBean> Elements typically contains <JSP: setProperty> elements for setting the properties of the bean. As mentioned above, the principal of <JSP: usebean> is only executed when the <JSP: UseBean> sample bean is executed, if this bean already exists, <JSP: usebean> can locate it, then the main body The content will not work</p> <p>Properties and usage</p> <p>ID = "BeanInstanceName"</p> <p>Confirm the parameters of the bean in the range you define, you can use this variable name to distinguish between different beans in the later program.</p> <p>This variable name is sensitive to case, and must meet the scripting language you are using, in Java Programming Language, this rule has been written in the Java Language specification. If this bean is already created in other <JSP: UseBean>, the value of this ID must be consistent with the original ID value. Scope = "Page | Request | Session | Application"</p> <p>The range of beans exists and the valid range of the ID variable name. The default is Page, the following is a detailed description:</p> <p>Page - You can use Beans in the JSP file containing <JSP: UseBean> element, and all static include files in this file until the page performs a response to the client or go to another file.</p> <p>Request - You use bean in any JSP file that performs the same request until the page is executed to respond to another file or go to another file. You can use the Request object to access bean, such as request.getattribute (BeanInstanceName)</p> <p>Session - From Creating a bean, you can use the bean in any JSP file using the same session. This bean exists within the entire session survival cycle, any JSP file in sharing this session can use the same bean. Note that you create BEAN's JSP file must specify session = true in the <% @ Page%> instruction</p> <p>Application - From Creating a bean, you can use the bean in any JSP file using the same Application. This bean exists within the entire Application Licheng period, any JSP file in sharing this Application can use the same bean.</p> <p>Class = "package.class"</p> <p>Use the new keyword and the Class constructor from a class from a class. This class cannot be abstract, there must be a public, no parameter constructor. This package is subject to case.</p> <p>TYPE = "package.class"</p> <p>If this bean already exists in the specified range, write this bean a new database type. If you don't use Class or BeanName to specify Type, Bean will not be sample. Package and Class's name, case sensitive.</p> <p>Beanname = "{package.class | <% = expression%>}" type = "package.class"</p> <p>Use the java.beans.beans.instantiate method to sample a bean from a Class or continuous template while specifying the type of the bean.</p> <p>Beanname can be Package and Class or an expression, it will pass the value of Beans.instantiate.TUPE can be the same as beans.</p> <p>Package and Class name are case sensitive.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-116593.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="116593" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.046</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'pBtKoPsb5_2BUGrWVDgD_2FtSCU9Oab2zXBbFwgF6HQkaxgxG3dab7h5CUqGKoRu7HMLFZu4ExLVYi7lmUBJMH_2B73w_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>