JSP基本语法

时间:2016.04.28 发布人:xxaxbbd123

JSP基本语法

已解决问题

谷歌xxaxbbd123用户在2016.04.28提交了关于“天堂岛JSP基本语法”的提问,欢迎大家涌跃发表自己的观点。目前共有1个回答,最后更新于2024-07-31T19:30:03。希望大家能够帮助她。

详细问题描述及疑问:期待您的答案,你无异于雪中送炭,让我感激涕零 !

希望以下的回答,能够帮助你。

第1个回答

用户名:ewzjn345  

  一,防种志同顶顶理艺初JSP元素

  1,脚本元素,包括表达式、程序码片段(包括内置类)、声明(成员变量和方法)、注释(输出和隐藏)

  2,指令元素,包括page(language,exte来自nds,import,session,buffer,autoFlush,isThreadSafe,info,errorPage,isErrorPage,contentType)、include(file)和taglib(ur331215问答i,prefix)。

  3,动作元素,系统元素:

 纸乱 jsp:includepage=?flush="true"(jsp1.1必须是这个)可以夹带jsp:param来添加request

  js燃生营器停也交零p:forwardpage=?可以夹带jsp:param来添加request

  士jsp:paramname=?value=?

  jsp:与老啊征具哥划阿客希plugin

  type="bean|applet"

  code="classfileName"

  codebase="classfilePathUrl"

  align=?点料亲设形茶烈带顺风height=?name=?东毫岩是武几广耐稳找分width=?hspace="与环绕文本之间的水平空白空间的大小"vspace=?

  archiv密局限第响显足e="标识包含对象能县倒路序的J**a类的.jar文件的URL"

  jrevision="标识组件需要的运行时环境JRE版本,默认1.1"

  title="ie使用的对象标题"

  nsplugi**rl="可以为Netscape下载JRE插件的URL"

  ieplug激迫i**rl="可以为IE下载JRE插件的URL"

  jsp:params由jsp:plugin封装一个js法p:action列表如jsp:param放在中间

  jsp:fallback轴题节维部守加载jsp:plugi皇着四足千叶敌依贵n失败时用来提供一个替代的的要医html响应,如一致轮营你段文本

  jsp:useBean

  id="实例名"

  scope="page|request|session|application"

  class="类名,若无type则须有class,若有be句权固件通行校命anName则须无class"

  beanName="a.b.c|a/b/c.cer,与class不两立"

  type="有同接口的类名,或类实现的接口名(只能使用接口中的方法)"

  jsp:setPropertyname="bean实例id"property="bean须有setPropertyName()的方法"[param=?]value=?若不指定value则从request中取与property名字相同或param名字相同的变量,若值为""不执行

  jsp:getPropertyname="beanid"property="bean属性,须有getPropertyName()方法"该动作元素直接输出

  4,空白字符:空格(0x20),Tab(0x09),回车(0x0d0a),jsp页面中的这些符号都会被out.println

  5,转义字符%>,,%>,',"都应当用转义

  二,隐藏对象

  1,requestj**ax.servlet.h**ttpServletRequest类型,

  StringgetParameter(StringparameterName);

  j**a.util.E**merationgetParamerterNames();

  String[]getParameterValues();

  ObjectgetAttribute(Stringname);

  j**a.util.E**merationgetAttributeNames();

  voidremoveAttribute(StringattributeName);

  voidsetAttribute(Stringname,Objectobject);

  j**ax.servlet.http.Cookie[]getCookies();

  j**a.util.E**merationgeth**eaderNames();//消息头

  j**a.util.E**merationgeth**eaders(StringheaderName);

  Stringgeth**eader(StringheaderName);

  intgetInth**eader(StringheaderName);

  longgetDateh**eader(StringheaderName);

  StringgetMethod();//请求方法

  StringgetRequestURI;//协议名和查询字符串之间,无主机名

  StringgetContextPath();//请求的文件所在的应用程序环境

  StringgetServletPath();//以contextPath为根,指定小程序或jsp所在的位置

  StringPathInfo();//额外的路径信息

  StringgetQueryString();

  booleanisSecure();//是否用了h**TTPS

  booleanisRequestedSessionIdFromCookie();

  booleanisRequestedSessionIdFromURL();

  booleanisRequestedSessionIdValid();//请求会话的ID是否有效

  j**a.util.LocalegetLocale();//客户同意内容所采取的Locale,取决于AcceptLanguge

  j**a.util.E**merationgetLocales();

  2,responsej**ax.servlet.http.h**ttpServletResponse

  intgetBufferSize();

  voidsetBufferSize(intsize);//

  booleanisCommitted();//写入状态码和报头后,响应是否已提交

  voidreset();//**缓存内的所有**包括状态码和报头

  voidflushBuffer();//强制缓存中的任何内容写入客户

  voidaddh**eader(Stringname,Stringvalue);

  voidseth**eader(Stringname,Stringvalue);

  voidaddDateh**eader(Stringname,longdate);

  voidsetDateh**eader(Stringname,longdate);

  voidaddInth**eader(Stringname,intvalue);

  voidsetInth**eader(Stringname,intvalue);

  booleancontainsh**eader(Stringname);

  voidsetContentType(Stringtype);

  voidsetLocale(j**a.uti.Locale,locale);

  voidsendError(intsc,Stringmsg);

  voidsendError(intsc);//状态码和描述性信息项客户发送错误响应

  voidsendRedirect(Stringlocation);

  3,pageContextj**ax.servlet.jsp.PageContext(由具体开发商完成具体化)

  /*intscope:

  ***.PAGE_SCOPE

  pageContext.REQUEST_SCOPE

  pageContext.**SSION_SCOPE

  pageContext.APPLICATION_SCOPE

  */

  ObjectgetAttribute(Stringname);//pageScope变量

  ObjectgetAttribute(Stringname,intscope);

  ObjectfindAttribute(Stringname);

  j**a.util.E**merationgetAttributeNamesInScope(intscope);

  intgetAttributeScope(Stringname);

  voidremoveAttribute(Stringname);

  voidremoveAttribute(Stringname,intscope);

  voidsetAttribute(Stringname,Objectobject);

  voidsetAttribute(Stringname,Objectobject,intscope);

  j**ax.servlet.jsp.JspWritergetOut();//out

  ExceptiongetException();//exception

  j**ax.servlet.ServletRequestgetRequest();//request

  j**ax.servlet.ServletResponsegetResponse();//response

  j**ax.servlet.http.h**ttpSessiongetSession();//session

  j**ax.servlet.ServletConfiggetServletConfig();//config

  j**ax.servlet.ServletContextgetServletContext();//application

  j**ax.servlet.jsp.JspWriterpopBody();

  j**ax.servlet.jsp.tagext.BodyContentpushBody();//管理taglib**的嵌套输出流

  voidforward(StringrelativeUrlPath);

  voidinclude(StringrelativeUrlPath);

  voidhandleException(j**a.lang.Exceptione);

  4,sessionj**ax.servlet.http.h**ttpSession

  //安装cookie

  //URL重写

  //SSL会话

  ObjectgetAttribute(StringattributeName);

  j**a.util.E**merationgetAttributeNames();

  voidsetAttribute(Stringname,Objectvalue);

  voidremoveAttribute(Stringname);

  longgetLastAccessedTime();//最后一次发送本次session相关**的时间

  /*关于long型时间:指从1970-1-100:00:00开始的毫秒数*/

  voidsetMaxInactiveInterval(intinterval);//秒为单位

  intgetMaxInactiveInterval();

  voidinvalidate();//使会话无效

  5,outj**ax.servlet.jsp.JspWriter

  //错误是会引发j**a.io.IOException

  voidclear();//**缓冲区,response.reset()?

  voidclearBuffer();//**缓冲区当前内容

  voidflush();//

  voidclose();//先刷新再关闭

  intgetBufferSize();

  intgetRemaining();//还没有使用的缓冲区

  booleanisAutoFlush();//pageautoFlush属性

  voidprint(Objectobject);

  voidprintln(Objectobject);

  6,applicationj**ax.servlet.ServletContext

  StringgetInitParameter(Stringname);

  j**a.util.E**merationgetInitParameterNames();

  ObjectgetAttribute(Stringname);

  voidsetAttibute(Stringname,Objectobject);

  j**a.util.E**merationgetAttributeNames();

  voidremoveAttribute(Stringname);

  //修改的时候,isThreadSafe最好设成false,而且用synchronized()

  j**a.net.URLgetResource(Stringpath);

  //URL::getPath()跟application.getRealPath()一样

  j**a.io.InputStreamgetResourceAsStream(Stringpath);//同URL::openStream();

  //RequestDispatcher:工作在服务器笑程序之间的服务

  j**ax.servlet.RequestDispatchergetNamedDispatcher(Stringname);//name为servlet的名称

  j**ax.servlet.RequestDispatchergetRequestDispatcher(Stringpath);//path为servlet的路径

  voidlog(Stringmessage);

  voidlog(Stringmessage,Throwablethrowable);//将一个消息和栈跟踪记录到小程序日志文件中

  StringgetMimeType(Stringfile);

  StringgetRealPath(StringvirtualPath);//URL::getPath

  StringgetServerInfo();

  intgetMajorVertion();

  intgetMinerVertion();

  7,configj**ax.servlet.ServletConfig

  StringgetInitParameter(Stringname);

  j**a.util.E**merationgetInitParameterNames();

  StringgetServletName();

  ServletContextgetServletContext();

  8,pagej**ax.servlet.jsp.h**ttpJspPage

  //通常不是JSP页面的创作者使用

  j**ax.servlet.ServletConfiggetServletConfig();

  StringgetServeletInfo();

  9,exceptionj**a.lang.Exception

  StringgetLocalizedMessage();

  StringgetMessage();

  voidprintStackTrace();

  voidprintStackTrace(j**a.io.PrintStreamps);

  voidprintStackTrace(j**a.io.PrintWriterpw);