开发者社区 问答 正文

为什么从JSP传值到action失败?

JSP:
<%
request.getSession().setAttribute("articleId", request.getParameter("id"));
%>
action:
Integer articleId = (Integer)request.getSession().getAttribute("articleId");
System.out.println(articleId);

最终打印出来的为null。

展开
收起
小旋风柴进 2016-03-17 13:42:47 2175 分享 版权
1 条回答
写回答
取消 提交回答
  • 你现确定jsp中request.getParameter("id")能不能取到值,这个方法通常在action里调用,用来取前台参数。
    你用其他的方式传值到action试试,form表单或者url

    2019-07-17 19:05:14
    赞同 展开评论
问答分类:
问答地址: