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
%>
假设在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
%>