Struts2标签诡异问题
程序员文章站
2022-05-23 19:07:59
...
在测试struts2标签的时候遇到了一个问题,怎么想也想不明白
index.jsp
<s:url var="aurl" namespace="/" action="aurl"> <s:param name="number" value="zhaoyp" /> <s:param name="password" value="123"/> <s:param name="age" value="11"/> </s:url> url:<s:property value="%{aurl}" /> <s:a href="%{aurl}">s:a和s:url使用</s:a>
action:
public class AurlAction extends ActionSupport implements SessionAware { private static final long serialVersionUID = -795351427940115962L; private String number; private String password; private Integer age; private Map<String, Object> sessionMap; public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String execute() throws Exception { System.out.println("number = " + number + " , password = " + password + ", age = " + age); sessionMap.put("number", number); sessionMap.put("password", password); sessionMap.put("age", age); return SUCCESS; } public void setSession(Map<String, Object> map) { Set<Map.Entry<String, Object>> set = map.entrySet(); for (Iterator iterator = set.iterator(); iterator.hasNext();) { Entry<String, Object> entry = (Entry<String, Object>) iterator .next(); System.out.println("key = " + entry.getKey() + " , value = " + entry.getValue()); } sessionMap = map; } public Integer getAge() { return age; } public void setAge(Integer age) { this.age = age; } public Map<String, Object> getSessionMap() { return sessionMap; } public void setSessionMap(Map<String, Object> sessionMap) { this.sessionMap = sessionMap; } public String getNumber() { return number; } public void setNumber(String number) { this.number = number; } }
Struts.xml
<action name="aurl" class="com.tag.action.AurlAction"> <result name="success">aurl.jsp</result> </action>
输出页面:
<body> <s:debug /> 用户名:<s:property value="%{number}"/> <br> 密码: <s:property value="%{password}"/><br> age:<s:property value="%{age}" /><br> session:<s:property value="%{sessionMap}"/> </body>
我用的struts2.2.1,怎么都无法取到number的值,但是password和age就ok,sessionMap中也只有password和age,没有number
推荐阅读
-
JS中如何实现点击a标签返回页面顶部的问题
-
jsp脚本、jsp声明、jsp输出表达式、javascript、jsp标签、struts2标签
-
Bootstrap开发中Tab标签页切换图表显示问题的解决方法
-
Bootstrap标签页(Tab)插件切换echarts不显示问题的解决
-
jsp 开发之struts2中s:select标签的使用
-
解决Laravel blade模板转义html标签的问题
-
用v-html解决Vue.js渲染中html标签不被解析的问题
-
关于vue v-for循环解决img标签的src动态绑定问题
-
解决video标签在安卓webview下无法自动播放问题
-
关于HTML5 Placeholder新标签低版本浏览器下不兼容的问题分析及解决办法