读书人

如何让strut2标签显示变量的值

发布时间: 2013-01-23 10:44:49 作者: rapoo

怎么让strut2标签显示变量的值

用了struts标签也可以使用java片段的。
可以将变量放入页面。
pageContext.setAttribute("param",param);
也可以将变量放到request或者session中
<%
String param = "hello";
request.setAttribute("param",param);
%>
<s:textfield name="param" value="%{#request.param}" />

也可以直接接收request范围的值

<s:textfield name="sno" value="%{#request.updateStudent.sno}"></s:textfield>//sno是Student类的属性

其中在action中是这样的

Students student2=new Students();
student2=StudentService.showUpdateStudent(student);
Map map=(Map)ActionContext.getContext().get("request");
map.put("updateStudent",student2);

读书人网 >互联网

热点推荐