1、死背JSP中九个内置对象及它的类型
JSP内建对象有以下几种:
名称 类型 使用范围
out javax.servlet.jsp.JspWriter page
pageContext javax.servlet.jsp.PageContext page
request javax.servlet.http.HttpServletRequest request
response javax.servlet.http.HttpServletResponse page
session javax.servlet.http.HttpSession session
application javax.servlet.ServletContext application
config javax.servlet.ServletConfig page
page java.lang.Object page
exception java.lang.Throwable page
2、reqeust的
常用方法都写一遍
示例:zhl_request_04_MethodAndMap中部分代码:
response.setContentType("text/html;charset=utf-8");
request.setCharacterEncoding("utf-8");
String checode=request.getCharacterEncoding();
String hp=request.getProtocol();
String hp1=request.getScheme();
String serverName=request.getServerName();
String ServletPath=request.getServletPath();
String uname=request.getParameter("user");
String pws=request.getParameter("password");
String RequestURL=request.getRequestURI();
String ContextPath=request.getContextPath();
int ServerPort= request.getServerPort();
String getMethod=request.getMethod();
System.out.println(checode);
System.out.println(hp);
System.out.println(hp1);
System.out.println(serverName);
System.out.println(ServletPath);
System.out.println(uname);
System.out.println(pws);
System.out.println(RequestURL);
System.out.println(ContextPath);
System.out.println(ServerPort);
System.out.println(getMethod);
输出结果:
utf-8
HTTP/1.1
http
localhost
/RequestMethod
小李
123
/Jsp/RequestMethod
/Jsp
8080
POST
3、获取遍历reqeust请求的参数名称及值
示例:zhl_request_04_MethodAndMap中部分代码:
Map Params=request.getParameterMap(); /*Map(k,v)*/
Set
> entrys=Params.entrySet();
for(Map.Entry entry:entrys){
String key= entry.getKey();
String[] value=entry.getValue();
System.out.print(key+"=[");
for(String String:value){
System.out.print(String +"|");
}
System.out.println("]");
}
输出结果:
sex=[男|]
爱好=[音乐|文学|]
password=[123|]
user=[小李|]
4、完成测试注册的程序
正在进行;
遇到问题:错误404
项目再次部署之后,在控制台中提示:严重The web application [/LoginReg] registered the JDBC driver [co
m.mysql.jdbc.Driver] but failed to unregister it
when the web application was stopped. To prevent a memory leak,the JDBC Driver has been forcibly unregistered.
是不是加载的驱动有问题,导入数据库夹包有问题。
5、前两次没交的补上
完成。