JSP[1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 lemonade 的 blog

. syntax summary

jsp element syntax interpretation notes
jsp expression
<%= expression %>
expression is evaluated and placed in output. xml equivalent is
<jsp:expression>
expression
</jsp:expression>
. predefined variables are request, response, out, session, application, config, and pagecontext (available in scriptlets also).
jsp scriptlet
<% code %>
code is inserted in service method. xml equivalent is
<jsp:scriptlet>
code
</jsp:scriptlet>
.
jsp declaration
<%! code %>
code is inserted in body of servlet class, outside of service method. xml equivalent is
<jsp:declaration>
code
</jsp:declaration>
.
jsp page directive
<%@ page att="val" %>
directions to the servlet engine about general setup. xml equivalent is
<jsp:directive.page att="val"\>. legal attributes, with default values in bold, are:
  • import="package.class"
  • contenttype="mime-type"
  • isthreadsafe="true|false"
  • session="true|false"
  • buffer="sizekb|none"
  • autoflush="true|false"
  • extends="package.class"
  • info="message"
  • errorpage="url"
  • iserrorpage="true|false"
  • language="java"
jsp include directive
<%@ include file="url" %>
a file on the local system to be included when the jsp page is translated into a servlet. xml equivalent is
<jsp:directive.include
  file="url"\>
.
the url must be a relative one. use the jsp:include action to include a file at request time instead of translation time.
jsp comment
<%-- comment --%>
comment; ignored when jsp page is translated into servlet. if you want a comment in the resultant html, use regular html comment syntax of <-- comment -->.
the jsp:include action
<jsp:include
    page="relative url"
    flush="true"/>
includes a file at the time the page is requested. if you want to include the file at the time the page is translated, use the page directive with the include attribute instead. warning: on some servers, the included file must be an html file or jsp file, as determined by the server (usually based on the file extension).
the jsp:usebean action <jsp:usebean att=val*/> or
<jsp:usebean att=val*>
...
</jsp:usebean>
find or build a java bean. possible attributes are:
  • id="name"
  • scope="page|request|session|application"
  • class="package.class"
  • type="package.class"
  • beanname="package.class"
the jsp:setproperty action
<jsp:setproperty att=val*/>
set bean properties, either explicitly or by designating that value comes from a request parameter. legal attributes are
  • name="beanname"
  • property="propertyname|*"
  • param="parametername"
  • value="val"
the jsp:getproperty action
<jsp:getproperty
    name="propertyname"
    value="val"/>
retrieve and output bean properties.  
the jsp:forward action
<jsp:forward
    page="relative url"/>
forwards request to another page.  
the jsp:plugin action
<jsp:plugin
    attribute="value"*>
  ...
</jsp:plugin>
generates object or embed tags, as appropriate to the browser type, asking that an applet be run using the java plugin.  

本文关键:JSP
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top