ITeye博客

jsp页面取struts2 action的变量供java、servlet使用

jiang_xiaohan · 2012-12-10 16:48 · jsp/servlet · Web前端 · Markdown

jsp页面通过 request对象直接获取 struts2 Action的变量的值。 假设在Action类里有这么一个变量

private String str = "Hello jsp and struts2";

还必须有str的get方法。

在JSP页面我们要引入org.apache.struts2.ServletActionContext <%@page import="org.apache.struts2.ServletActionContext"%>

然后 <% String str = request.getAttribute("str"); System.out.println(str); //结果将输出: Hello jsp and struts2 %>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。