猿问

不能向页面传值

protected void doGet(HttpServletRequest req, HttpServletResponse resp)

throws ServletException, IOException {

// 设置编码

req.setCharacterEncoding("UTF-8");

// 接受页面得值

String command = req.getParameter("command");

String description = req.getParameter("description");

// 想页面传值

req.setAttribute("command", command);

req.setAttribute("description", description);

QueryService  listService =  new QueryService();

// 数据传输值

req.setAttribute("messageList", listService.queryMessageList(command, description));

// 查询消息列表并传值

req.getRequestDispatcher("/WEB-INF/jsp/back/list.jsp").forward(req, resp);

}

@Override

protected void doPost(HttpServletRequest req, HttpServletResponse resp)

throws ServletException, IOException {


小荨3408782
浏览 1299回答 1
1回答

丶包菜

页面传过来请求叫Request,你给页面传值叫Response。可是你一直在操作Request
随时随地看视频慕课网APP

相关分类

Java
我要回答