servletpackage servlet;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.RequestDispatcher;import javax.servlet.ServletException;import java.io.*;impo
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/27 13:29:39
servletpackage servlet;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.RequestDispatcher;import javax.servlet.ServletException;import java.io.*;impo
servlet
package servlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import java.io.*;
import bean.UserBean;
//用户注册
public class RegistServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException{
response.setContentType("text/html;charset=UTF-8");
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
UserBean user=new UserBean();
String name=request.getParameter("name");
String password=request.getParameter("password");
String trueName=request.getParameter("trueName");
String tel=request.getParameter("tel");
String address=request.getParameter("address");
user.setName(name);
user.setPassword(password);
user.setTrueName(trueName);
user.setTel(tel);
user.setAddress(address);
if(user.newUser(user))
{
RequestDispatcher dis=request.getRequestDispatcher("/index.jsp");
dis.forward(request,response);
}
}
public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException{
doGet(request,response);
}
}
index.jsp
%@page contentType="text/html;charset=UTF-8"%>
订餐系统
用户名 | |
密码 | |
web.xml部分
UserLogon
servlet.UserServlet
UserLogon
/index.jsp
报错:message HTTP method GET is not supported by this URL
description The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).
tomcat版本:6.0.20
servletpackage servlet;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.RequestDispatcher;import javax.servlet.ServletException;import java.io.*;impo
/index.jsp
这两个不一致,淡然请求会出问题