可以在业务控制方法中书写传统web参数,这种方式我们不提倡,耦合了
@Controller @RequestMapping(value="/user") public class UserAction{ @RequestMapping(value="/add",method=RequestMethod.POST) public void add(HttpServletRequest request,HttpServletResponse response) throws Exception{ System.out.println("HelloAction::add()::POST"); int id = Integer.parseInt(request.getParameter("id")); String name = request.getParameter("name"); double sal = Double.parseDouble(request.getParameter("sal")); System.out.println(id + ":" + name + ":" + sal); request.getSession().setAttribute("id",id); request.getSession().setAttribute("name",name); request.getSession().setAttribute("sal",sal); response.sendRedirect(request.getContextPath()+"/register.jsp"); } }
原文地址:https://www.cnblogs.com/loaderman/p/10063298.html
时间: 2024-10-30 06:30:12