概述
package web;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class RegisterServlet extends HttpServlet {
@Override
protected void service(
HttpServletRequest req,
HttpServletResponse res) throws ServletException, IOException {
//1.接受请求数据
String name=req.getParameter("userName");//接受表单数据
String pwd=req.getParameter("password");
String sex=req.getParameter("sex");
String[] interests =
req.getParameterValues("interest");//接受多个数据
//2.处理业务
System.out.println(name);
System.out.println(pwd);
System.out.println(sex);
if(interests !=null) {
for(String interest:interests) {
System.out.println(interest);
}
}
//3.发送响应数据
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.println("<p>register success</p>");
out.close();
}
}
最后
以上就是糊涂山水为你收集整理的RegisterServlet class part2的全部内容,希望文章能够帮你解决RegisterServlet class part2所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复