日期:2014-05-18 浏览次数:20798 次
<%@ page language="java" import="java.util.*,com.bean.Bean" pageEncoding="UTF-8"%>
<%@ page contentType="text/html; charset=GBK" %>
<title>a.jpg</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<form name="add" method="post" action="AddServlet">
<table align="center" border="0" width="995">
<tr><td><%String n=request.getParameter("a");%>
String name = new String(n.getBytes("iso-8859-1"),"gb2312");</td>
<td><input type="text" name="name" value="<%=name%>"></td>
</tr>
</table>
</form>
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html; charset=GBK");
request.setCharacterEncoding("GBK");
Bean b=new Bean();
rb.setName(request.getParameter("name"));
…………
String b=request.getParameter("name");
response.sendRedirect("a.jsp?a="+b);
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String b = request.getParameter("name");
byte[] bytes = b.getBytes("iso-8859-1");