Struts2 二、为Action的参数注入值
2016-12-01 00:00
363 查看
为Action参数注入值,主要使用在的场景为,Action的一个参数的值不是固定的是可以改变的,所以不能直接写在Action中,可以通过Struts配置的方式将值配置到Struts中,然后通过注入的方式将值注入到Action中,下面是代码:
struts-config代码:
message.jsp代码:
访问地址:http://localhost:9000/Struts2/hello/helloAction_sayHello.do
public class HelloAction { public String resultParam; public String sayHello(){ return "message"; } public String getResultParam() { return resultParam; } public void setResultParam(String resultParam) { this.resultParam = resultParam; } }
struts-config代码:
<package name="hello" namespace="/hello" extends="struts-default"> <action name="helloAction_*" class="cn.actions.HelloAction" method="{1}"> <param name="resultParam">我的名字是:</param> <result name="message">/WEB-INF/pages/message.jsp</result> </action> </package>
message.jsp代码:
<body> ${resultParam} 杰克 </body>
访问地址:http://localhost:9000/Struts2/hello/helloAction_sayHello.do
相关文章推荐
- Struts2 二、为Action的参数注入值
- Struts2 二、为Action的参数注入值
- Struts2 二、为Action的参数注入值
- Struts2中自定义拦截器导致Action注入参数丢失
- Struts2使用自定义拦截器导致Action注入参数丢失、url参数
- Struts2中自定义拦截器导致Action注入参数丢失
- spring 整合struts2 action参数设置不上
- Struts2中action重定向跳转到jsp页面两种配置方式带参数
- 在Struts2拦截器中获取请求action名称及参数
- struts2的action的知识点和利用action向页面注入值的操作
- struts2--(3)--一些小知识点---action接收参数问题
- 对struts2的action接收参数的理解
- Struts2 Action属性接收参数中文问题
- struts2 action中传递两个参数到url
- Struts2中Action接收参数的方法
- Struts2 学习笔记 —— 10 —— Action接收参数时的中文乱码问题
- struts2中action接收参数的方法
- struts2表单提交action路径传参数不成功
- struts2 redirect-action 传递参数问题
- Struts2中Action接收参数