实习16
修改改动
增加代码
ToUpServlet
package com.zhongruan.servlet;
import com.zhongruan.model.User;
import com.zhongruan.service.UserService;
import com.zhongruan.service.impl.UserServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;
public class ToUpServlet extends HttpServlet {
UserService userService=new UserServiceImpl();
@Override
protected void doGet(HttpServletRequest requst, HttpServletResponse respost) throws ServletException, IOException {
String ids=requst.getParameter("id");
int sid=Integer.parseInt(ids);
User user=userService.findUserById(sid);
HttpSession session=requst.getSession();
session.setAttribute("user",user);
requst.getRequestDispatcher("upUser.jsp").forward(requst,respost);
}
}