JSP第三天

el表达式语言的作用:
 获取数据并显示
 参数
  ${param.参数名}
  ${paramValues.参数名[i]}
 属性
  ${**Scope.属性名}
  ${属性名}
   request-->session-->application
 获取request对象
  ${pageContext.request.contextPath}
逻辑分支控制语句:
 JSTL:java standard tag libarary     java标准标签库
 html中嵌入java代码,<起始标签 属性名="属性值">标签体</结束标签>

 <前缀:center>hehe</前缀:center>

JSTL标签具有的内容:
 1 约束标签书写规则的文档:
 tld文件--tag libarary defination标签库的定义文件
 2 标签处理类,提供标签所具有的功能

JSTL的标签分类:
 c:  core核心标签库
 sql:访问操作数据库的标签库 
 x:  操作xml文件的标签库
 fmt:格式化显示信息、国际化的标签库

tld文件的内容:
 <description>JSTL 1.1 core library</description> 标签库描述信息
   <display-name>JSTL core</display-name>
   <tlib-version>1.1</tlib-version>
   <short-name>c</short-name>    统一前缀
   <uri>http://java.sun.com/jsp/jstl/core</uri>  标示当前标签库唯一的逻辑地址

  <tag>           一组标签定义
    <description>
        Catches any Throwable that occurs in its body and optionally   描述当前标签的作用
        exposes it.
    </description>
    <name>catch</name>         标签名
    <tag-class>org.apache.taglibs.standard.tag.common.core.CatchTag</tag-class>  当前标签对应的处理类
    <body-content>JSP</body-content>       标签体的内容类型  
    <attribute>          标签的属性
        <description>         标签属性的功能描述
Name of the exported scoped variable for the
exception thrown from a nested action. The type of the
scoped variable is the type of the exception thrown.
        </description>
        <name>var</name>        属性名
        <required>false</required>       定义当前属性是否必须存在  
        <rtexprvalue>false</rtexprvalue>      当前属性的值是否支持el表达式
 <type>...         属性值的类型,默认是string
    </attribute>
  </tag>


jsp:
 html  负责显示
 javaScript 负责客户端的格式化校验
 jstl  负责逻辑分支语句
 el  负责获取数据并显示

c标签库:
 *1 <c:if test="1>2">hehe</c:if>
 ===>
 if(1>2){
  <%="hehe"%>
 }
 
 <c:if test="${1 gt 2 }" var="flag" scope="request">
  hehe
 </c:if>
 ==>
 var flag = ${1 gt 2 };
 request.setAttribute("flag",flag);
 if(flag){
  <%="hehe"%>
 }

 *2
 <c:choose>
  <c:when test="${param.age < 20}">
   小孩儿~!
  </c:when>
  <c:when test="${param.age >= 20 && param.age < 40}">
   青年人
  </c:when>
  <c:otherwise>
   老啦~!
  </c:otherwise>
 </c:choose>
 ==>
 switch(..){
  case ..:
  case ..:
  ..
  default:
 }
 *3
 <c:for
 ==>
 int count = request.getParameter("count"); 
 int info= request.getParameter("info");
 for(int i = 1 ; i < count ; i++){
  <%=info%>
 }

 <c:forEach items="${strs}" var="entry">
  ${entry.key } === ${entry.value }<br>
 </c:forEach>
 ==>
 Map strs = ${strs};
 Set<Map.Entry> entrys = strs.entrySet();
 for(Map.Entry entry : entrys){
  entry.getKey();
  entry.getValue();
 }

 4 <c:set scope="request" value="123" var="as"></c:set>
 ==》
 request.setAttibute("as",123);

 5 <c:remove var="as"/>
 ==>
 【pageContext.remove("as",PageScope.REQUEST_SCOPE)】
 pageContext.remove("as");
  将当前jsp页面所在的web应用中所有名为as的属性全部移除
 6
 <c:redirect url="../../../stuMgmt"></c:redirect>
 ==》
 response.sendRedirect可以跨应用跳转
 注意:
  <c:redirect>中的绝对路径,起始点为【/应用名】

 7 <c:import url="for.jsp"></c:import>
 ==>
 <jsp:include page="for.jsp"/>
 
 
 i18n:
  internationalization国际化

  1 提供多个不同语言的资源文件
   resourse_zh.properties
    name=张三
   resourse_es.properties
    name=zhangsan

  2 提供一个类,先获取当前系统所支持的语言格式zh,动态查找其对应的资源文件_zh
    提供一个方法,根据统一的某一个key查找对应值
 
  3 jsp中调用上述类的方法,动态获取具体显示的信息
   

 

 dom解析:
  1 DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
  2 DocumentBuilder b = f.newDoucmentBuilder();
  3 Document doc = b.parse("");
  4 Element root = doc.getDocumentElement();
  5 NodeList ns = root.getElementsByTagName("");
    for(int i = 0 ; i < ns.getLength(); i++){
   Element e = (Element)ns.item(i);
   ....
   
          }/
  ns.item(0).getFirstChild().getNodeValue();
   
 doc/games/country/athlete

java_home=...
path=%java_home%/bin

set NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK
set NLS_LANG=AMERICAN_AMERICA.USACII7

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值