首页 > 技术文章 > jsp留言板

jakeasd 2016-06-26 11:57 原文

1、留言板代码

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="lianxi2.jsp" method="post">
<table width="500" height="400" border="1" cellpadding="0" cellspacing="0"style=""font:9pt;"
bordercolordark="#666666" bordercolorlight="#FFFFFF" bordercolor="#FFFFFF">
<tr height="40" align="center"><td>留言簿</td></tr>
<tr ><td>
<textarea name="name" rows="25" cols="80"></textarea>
</td></tr>
<tr>
<td align="center" coslspan="2">
<input type="submit" value="提交留言">
</td>
</tr>
</table>

</form>
</body>
</html>

 运行及输入留言:

2、留言转码并输出代码

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

<table width="500" height="400" border="1" cellpadding="0" cellspacing="0"style=""font:9pt;"
bordercolordark="#666666" bordercolorlight="#FFFFFF" bordercolor="#FFFFFF">
<tr height="40" align="center"><td>感谢您的留言</td></tr>
<tr align="center"><td>
<% 
String name=new String(request.getParameter("name").getBytes("ISO-8859-1"),"UTF-8");
out.print(name);
%>
</td></tr>

</table>

</body>
</html>

 运行结果:

 

推荐阅读