2018.3.2李锦浩【连续第143天】
今天完成最后的一个user的jsp页面,并对前几天的编程页面进行调试,发现了在jsp页面的编写过程中变量名一旦写错,程序不会报错,只会出现显示不出的问题,难以查找,因此在编写的过程中格外注意变量名的问题。
附:
<%@ page language="java" import="java.util.*,java.net.*"pageEncoding="utf-8"%>
<%
Stringpath = request.getContextPath();
StringbasePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTDHTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'user.jsp' starting page</title>
<meta http-equiv="pragma"content="no-cache">
<meta http-equiv="cache-control"content="no-cache">
<meta http-equiv="expires"content="0">
<meta http-equiv="keywords"content="keyword1,keyword2,keyword3">
<meta http-equiv="description"content="This is my page">
<!--
<link rel="stylesheet"type="text/css" href="styles.css">
-->
</head>
<body>
<h1>用户信息</h1>
<hr>
<%
request.setCharacterEncoding("utf-8");
String username="";
String password="";
Cookie[] cookies=request.getCookies();//读取cookie
if(cookies!=null&&cookies.length>0){
for(Cookie c:cookies){
if(c.getName().equals("username"))
{
username=URLDecoder.decode(c.getValue(),"utf-8");//用于解码和转码
}
if(c.getName().equals("password"))
{
password=URLDecoder.decode(c.getValue(),"utf-8");
}
}
}
%>
<br>
<br>
<br>
用户名:<%=username%><br>
密码:<%=password%><br>
</body>
</html>
明日任务:继续学习javaweb。