【发布时间】:2017-04-17 07:23:13
【问题描述】:
请检查下面的代码,我将数据从我的Servlet 附加到RequestDispatcher
request.setAttribute("userInfo", userInfo);
request.setAttribute("userProfession", userProfession);
request.setAttribute("userQualification", userQualification);
RequestDispatcher dispatch = request.getRequestDispatcher("/WEB-INF/jsp/profile.jsp");
dispatch.forward(request, response);
所有附加属性均为beans。
在我的JSP 中,我得到如下数据。
<head>
<%@taglib prefix="c" uri= "http://java.sun.com/jsp/jstl/core" %>
</head>
<body>
<h5>Name</h5>
<p class="xpanel_txt1"><c out="${userInfo.firstName}"/> <c out=" "/> <c out="${userInfo.lastName}"/></p>
</body>
现在有趣的部分是,当显示网站 JSP 时,我只看到一个空白字段,应该输入上述数据。但是,如果我在谷歌浏览器中打开inspector,我可以看到数据已经加载。
为什么会这样?
【问题讨论】:
标签: java html jsp servlets requestdispatcher