javaservlet
Posted 哈哈呵
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javaservlet相关的知识,希望对你有一定的参考价值。
import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class acceptUserRegist extends HttpServlet { public String codeToString(String str) {//处理中文字符串的函数 String s=str; try { byte tempB[]=s.getBytes("ISO-8859-1"); s=new String(tempB); return s; } catch(Exception e) { return s; } } public void init(ServletConfig config) throws ServletException { super.init(config); } public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException { //设置mime response.setContentType("text/html;charset=GB2312"); PrintWriter out=response.getWriter(); out.println(""); out.println("这是新用户注册所提交的数据:"); out.println("用户名是:"+codeToString(request.getParameter("username"))+"
"); out.println("密码是:"+codeToString(request.getParameter("userpassword"))+"
"); out.println("性别是:"+codeToString(request.getParameter("sex"))+"
"); out.println("出生年月是:"+request.getParameter("year")+request.getParameter("month")+request.getParameter("day")+"
"); out.println("电子邮箱是:"+request.getParameter("email")+"
"); out.println("家庭住址是:"+codeToString(request.getParameter("address"))+"
"); out.println(" "); } }
以上是关于javaservlet的主要内容,如果未能解决你的问题,请参考以下文章