1.当使用type=“redirectAction” 或type=“redirect”提交到一个action并且需要传递一个参数时。这里是有区别的:
使用type=“redirectAction”时,结果就只能写Action的配置名,不能带有后缀:“.action”
Map sessionMap = ActionContext.getContext().getSession();
sessionMap.put("qi", qi);
3.
public class LoginAction extends ActionSupport {
private User user;
//用于保存请求重定向到的action的名字
private String nextAction;
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String getNextAction() {
return nextAction;
}
public void setNextAction(String nextAction) {
this.nextAction = nextAction;
}
@Override
public String execute() throws Exception {
System.out.println("***************** "+user.isManager());
//如何把user的manager传入的字符转换成boolean类型?
if(user.isManager())
nextAction="manager";
else
nextAction="employee";
return SUCCESS;
}
}
<action name="login"
class="act.LoginAction">
<result type="redirectAction">${nextAction}?name=${user.name}</result>
<!-- LoginAction里的属性值name传到nextAction ,传递中文出现乱码-->
</action>
<action name="employee"
class="act.EmployeeAction">
<result>/result.jsp</result>
</action>
<table border="1">
<s:form action="/loginns/login.action">
<tr>
<td><s:textfield name="user.name" label="用户名" cssStyle="width:120px;"></s:textfield></td>
</tr>
<tr>
<td><s:password name="user.password" label="密码" cssStyle="width:120px;"></s:password></td>
</tr>
<tr><!-- 传入的值如果不是true,其它的都转换成false -->
<td><s:radio name="user.manager" value="false" list="#{true:'是',false:'否'}" label="是否管理员"></s:radio></td>
</tr>
<tr>
<td align="center"><s:submit value="登陆"></s:submit></td>
</tr>
</s:form>
</table>
${param.name }(el)美元符号是El表达式
<s:property value="#parameters.name"/>(ognl)这个是OGNL来获取值