我用的是struts2
我想从action里面获取一些数据(暂时设定为常量)然后传到前台显示出来,可是怎么也不成功,
action中这个变量我是写在action的私有变量里面的,而且在execute方法中也赋了值,在前台就是显示不出来。
前台我是用的struts标签,而且程序完全是参照网上的helloword来写的,不知道是不是配置文件问题。需要注意到什么地方?
我想从action里面获取一些数据(暂时设定为常量)然后传到前台显示出来,可是怎么也不成功,
action中这个变量我是写在action的私有变量里面的,而且在execute方法中也赋了值,在前台就是显示不出来。
前台我是用的struts标签,而且程序完全是参照网上的helloword来写的,不知道是不是配置文件问题。需要注意到什么地方?
不用标签也不行
代码如下:
<%@ page language="java" contentType="text/html; charset=utf-8" %>
<%@ page import="java.util.*,com.opensymphony.xwork2.util.*" %>
<html>
<head>
<title>asdfasdf</title>
</head>
<body>
<table border="1" width="360">
<caption>ffff</caption>
<%
ValueStack vs = (ValueStack)request.getAttribute("struts.valueStack");String[] books = (String[])vs.findValue("books");
%>
<tr>
<td>sdfasfasf</td>
<td><%=books.length%></td>
</tr></table>
</body>
</html>