【发布时间】:2014-05-10 03:53:41
【问题描述】:
由于某些原因(应用程序的现有设计),我需要使用 jsp include 在 jsp 中调用控制器方法。我需要访问父jsp中控制器中的设置属性。 下面是我的控制器:
@Controller
@SessionAttributes({"profile"})
@RequestMapping("/manageMyAccount")
public class MyPageDataController {
@RequestMapping(value="/",method=RequestMethod.GET)
public void initData(HttpServletRequest request, Model model, HttpSession session) {
Profile profile = (Profile) session.getAttribute("profile");
model.addAttribute("test", "success");
model.addAttribute("profile", profile);
}
}
JSP 代码:
jsp:include page="/mvc/manageMyAccount/"/>
我试图在 jsp 中以${test} 的上述语句后获取 jsp 中的数据,但我变得空白。
【问题讨论】:
-
测试未设置在任何范围内。试试 ${profile.test}。个人资料正在会话中。
-
谢谢,但我也无法获取个人资料。使用 ${profile}
-
我需要这个jsp上的某些数据/对象,并在Controller中设置为模型属性。如何将它们设置为控制器中的范围。我不希望他们参加会议。
-
我可以获取个人资料。但是有没有办法在jsp中获得“test”属性?
-
你做了什么,现在你可以得到个人资料?
标签: java jsp spring-mvc