Ray-Yan
2016-09-25 14:02
采纳率: 100%
浏览 3.4k
已采纳

Servlet获取不到JSP页面上的值

如下是Servlet代码:

 public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        HttpSession session = request.getSession();
        //String account = (String) request.getAttribute("account");
        String account = request.getParameter("a");
        System.out.println("--------------------------------"+account);
        List<Teacher> oneTeaInfo = new ArrayList<Teacher>();
        try {
            oneTeaInfo = new TeacherDao().queryTeaInfo(account);
            session.setAttribute("oneTeaInfo", oneTeaInfo);
            request.getRequestDispatcher("/teacher_info.jsp").forward(request,response);
        } catch (Exception e) {
            e.printStackTrace();
        } 
    }

如下是JSP的相关代码:

 <input type="text" name="a" value="666666" />

我是把值写死的,不写死的情况下,代码如下:

    <c:set var="account" value="${sessionScope.account}" scope="request"/>

居然运行结果是空值,如下图所示:
图片说明
图片说明
请问各位大神,应该如何解决这个问题?

9条回答 默认 最新

相关推荐 更多相似问题