麻烦看下我这段代码哪里出错了吗,新增员工会出现服务器内部错误
package com.xiaocai.employee; import java.io.IOException; import java.util.List; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Servlet implementation class EmployeeServlet */ @WebServlet("/EmployeeServlet") public class EmployeeServlet extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public EmployeeServlet() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doPost(request, response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //设置编码方式 request.setCharacterEncoding("utf-8"); //获取客户端请求的参数值 String empon=(String)request.getAttribute("empno"); String ename=(String)request.getAttribute("ename"); String department=(String)request.getAttribute("department"); String job=(String)request.getAttribute("job"); String salary=(String)request.getAttribute("salary"); Employees emp=new Employees(Integer.parseInt(empon),ename,department,job,Float.parseFloat(salary)); ServletContext context=request.getServletContext(); List employees=(List)context.getAttribute("employees"); //将请求的参数保存到集合当中 employees.add(emp); context.setAttribute("employees", employees); //请求转发到下一个页面 request.getRequestDispatcher("/employee.jsp").forward(request, response); } }
0
收起
正在回答 回答被采纳积分+1
4回答
qq_Rotation轻描_0
2019-04-10 14:29:18
相似问题
登录后可查看更多问答,登录/注册
从网页搭建入门Java Web2018版
- 参与学习 人
- 提交作业 1088 份
- 解答问题 10205 个
如果你有Java语言基础,又想以后从事Java Web开发,那么本路径是你的不二选择!本路径从网页搭建开始入手,通过大量案例来学习Java Web基础。定能助你完成Java Web小白的蜕变!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星