首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 互联网 >

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

2013-01-23 
怎么让strut2标签显示变量的值用了struts标签也可以使用java片段的。可以将变量放入页面。pageContext.setAt

怎么让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);

热点排行