jsp复习笔记
来源:互联网 发布:字体识别软件 编辑:程序博客网 时间:2024/06/10 02:28
1.jsp技术是用JAVA语言作为脚本语言的。
2.<% %> <%= %>
3.<%! %>
4.form表单
enctype=”” application默认 multipart/form-data文件字节流
URL参数值长度不能超过2K
get post
action=”提交路径”
5.三大指令 page taglib include
<%@指令 [属性] %> <%@ page contentType="text/html;charset=UTF-8" language="java" import="" pageEncoding="utf-8"%> contentType 从服务器端到客户端的语言类型,此页编码方式 language="java" java语言 import="" 引入包 pageEncoding="utf-8" 此页request接收到参数以什么字符集来编码 (注意:三个地方UTF-8 再加上<meta charset="utf-8"> ) <%@ include file="文件路径名"%> 缺陷:不方便传参,把代码都会include进去,所以要避免首部尾部标签重复 <%@ taglib%>
6.jsp六个基本动作
<jsp:useBean id="a" class="com.lyf.Animal">//动作实例化 <jsp:setProperty name="a" property="name" value="cat"/> </jsp:useBean> <jsp:getProperty name="a" property="name"> <jsp:include page="" >//动作include 可以传参 <jsp:include file="index.jsp"> <jsp:param name="username" value='<%=java.net.URLEncoder.encode("中文","utf-8")%>'/> </jsp:include> <% String name=request.getParameter("username"); %> <%=java.net.URLDecoder.decode("中文","utf-8")%> <jsp:forward page="">//一次请求 <jsp:param name="username" value='<%=java.net.URLEncoder.encode("中文","utf-8")%>'/> </jsp:forward>
7.jsp内置对象
page<request<session<application out response request session config application exception pageContext page out.println("")源代码换行,实际效果不换行 request.getParamter request.getCookies request.setAttribute request.getAttribute request.getSession request.getParameterValues request.getParameterNames response.addCookie response.setContentType response.sendRedirect response.setHeader
8.session//用于会话请求,可以跨页请求 request//用于一次请求
session.setAttribute session.getAttribute session.removeAttribute 设置session时间 web.xml <session-config> <session-timeout>30</session-timeout>//30分钟 </session-config>
9.application//所有页都可以传 可用于在线访客
web.xml <context-param> <param-name>count</param-name> <param-value>1000</param-value> </context-param> <% String count=application.getInitParameter("count"); if(application.getAttribute("num")==null) { application.setAttribute("num",count); } int num=Integer.parseInt(application.getAttribute("num").toString()); application.setAttribute("num",++num);%>
10.pageContext//页面赋值
11.@include :指令,不能传参 先合成后编译
jsp:include :动作,能传参,先编译后合成
12.
response.setContentType("text/html");//相应格式 response.setRedirect(""); //window.location Cookie c=new Cookie("username","ff"); c.setMaxAge(3600*24*7); response.addCookie(c); Cookie[] cookies=request.getCookies(); for(Cookie c:cookies){ if(c.getName().equals("ff"){ } }
阅读全文
0 0
- jsp复习笔记
- jsp 内置对象 复习笔记
- Servlet和JSP复习笔记
- Servlet和JSP复习笔记
- Servlet和JSP复习笔记
- JSP/Servlet复习笔记(一)
- JavaEE复习笔记(2)——JSP
- JSP复习
- jsp复习
- 复习jsp
- JSP复习
- JSP复习
- JSP复习
- jsp复习:
- JSP复习
- JSP复习
- [jsp]jsp复习重点
- 复习笔记
- Degree Sequence of Graph G(Hdu_oj 2454)
- HBase也疯狂
- Leetcode:240. Search a 2D Matrix II (week 11)
- PCL编程宝典-代码编译常见问题及解决办法
- postman使用
- jsp复习笔记
- PyPI使用国内源
- 微信小程序开发-路由
- 11.11学习笔记之keras的sequential模型
- 在spring mvc应用中创建第一个Controller
- c语言:用switch模拟售货机
- android 使用控件webView 与 vue交互
- Java 8 函数式编程学习笔记
- Java文件操作自己做的一些小实验