jsp-------plastic

E:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\jspFirstt\org\apache\jsp
servlet的技术可以用在jsp中
jsp中的技术,不是全部应用再servlet程序中
<%=表达式,变量或者表达式%>  作用,向浏览器输出变量值或者表达式计算的记过
jsp表达式<%=变量或者表达式%>向浏览器输出变量的值或者表达式的计算结果
jsp脚本<%java代码%>其中 的java代码会原封不动的复制到翻译后的java文件(servlet)中
jsp声明<%!成员变量或者成员方法%>,
jsp的注释<%--不翻译,不执行--%>在jsp页面中,不用html的注释
jsp的三大指令:include<%@include file="/common/1.jsp"%>静态包含,先合并jsp文件,再翻译为一个java文件
:page<%@page language="java" import="java.util.*" contentType="text/html;charset=utf-8" pageEncoding="utf-8"%>
errorPage:错误处理页面
isErrorPage:true、false指定当前是否为错误页面
web。xml中配置全局的错误页面
<errorPage></errorPage>
seesion:表示是否开启session功能
false:不可以用session内置对象,如果true可以用session内置对象
buffer:jsp页面缓冲区大小
jsp的内置对象。
内置对象:
对象类型 对象名
HttpServletRequest   request
HttpServletResponse   response
ServletConfig config
ServletContext application
HttpSession session
Throwable exception
Object page(this)
JSPWriter out
PageContext pageContext


out对象:JSPWriter  带缓冲的PrintWriter();通过PrintWriter writer=response.getWriter();writer.write():直接向浏览器输出内容。
out.write():向JSP缓冲区写出内容。
buffer:默认8Kb
pageContext封装八大对象
JSPWriter out=pageContext.getOut();
servlet里面有三个域对象
servletContext   application
//request转发技术
request.getRequestDispatcher("/03.pageContext2.jsp").forward(request,response);
//response重定向技术
response.sendRedirect(request.getContextPath()+"/03.pageContext2.jsp");


保存数据:默认保存到page域中,,pageContext.setAttribute();
向四个域中保存常量
pageContext.PAGE_SCOPE
pageContext.REQUEST_SCOPE
pageContext.SESSION_SCOPE
pageContext.APPLICATION_SCOPE
获取数据
默认从page域中获取
可以从四个域中获取pageContext.getAttribute("name",..);


搜索数据
pageContext.findAttribute("name");
page-->request-->session--->context(ServletContext)
el表达式:向浏览器输出变量值或者结果
${变量或者表达式}
从四个域获取
${name}
从指定域获取
${pageScope.name}
pageScope /requestScope/sessionScope/applicationScope
输出对象的属性值
el表达式没有遍历功能
${ empty name}判空
list map
//创建list对象
List<Student> list=new ArrayList<Student>();
list.add(new Student("rose",20));
list.add(new Student("jack",23));
list.add(new Student("lucky",28));
//把list放到域中
pageContext.setAttribute("list",list);

//创建一个map集合
Map<String,Student> map=new HashMap<String,Student>();
map.put("100",new Student("mark",10));
map.put("101",new Student("lily",30));
map.put("102",new Student("jacpky",45));
//把map放入到page域中
pageContext.setAttribute("map",map);
判空::${empty name}<br/>
jsp标签的作用::替换掉jsp脚本<% %>
el表达式作用::替换jsp表达式<%=  %>


<jsp:forward>标签(内置)


<jsp:forward page="/09.action2.jsp">
<jsp:param value="jacky" name="name"/>
<jsp:param value="123456" name="password"/>
</jsp:forward>
<jsp:include >标签(内置,动态包含)
<jsp:include page="/common/header.jsp"></jsp:include><hr/>


(内置)
<%@  include file="/common/02.jsp"%>
<jsp:include page=""></>


jsp标签
(1)内置标签
jsp:forward----->跳转文件。
jsp:param------->包含文件或者跳转时传递的参数
jsp:include------>包含其他文件,动态包含
(2)jstl标签:java standard tag language
核心标签库 :(C:)
国际化标签库(fmt:)
EL函数库(fn函数库)
<c:set var="name" value="rose"></c:set>


<c:out value="${msg}" default="默认值"></c:out>


<c:out value="${msg}" default="<h3>标题3</h3>" escapeXml="false"></c:out>


<c:if test="false">
条件成立,显示内容。
</c:if>


<c:choose>
<c:when test="${score>=90 && score<=100}">
优秀
</c:when>
<c:when test="${score>=80 && score<90 }">
良好
</c:when>
<c:when test="${score>=70 && score<80 }">
一般
</c:when>
<c:when test="${score>=60 && score<70 }">
及格
</c:when>
<c:otherwise>
不及格
</c:otherwise>
</c:choose>


list有顺序,map没有顺序
<c:forEach begin="0" end="2" items="${list }" step="2" var="student" varStatus="varSta">
序号:${varSta.count }--姓名:${student.name }----年龄:${student.age }<br/>
</c:forEach><hr/>
<c:forEach items="${map }" var="entry">
序号:${entry.key }---姓名:${entry.value.name }---年龄:${entry.value.age }<br/>


</c:forEach>


<c:redirect url="http://www.baidu.com"></c:redirect>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值