java class:
public class UserAction extends Action {
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
throws Exception
{
switch
case 1: return actionMapping.findForward("f1");
case 2: return actionMapping.findForward("f2");
}
}
struts-config:
<action path="/aaa" type="UserAction" name="aaaForm" validate="false">
<forward name="f1" path="/f1.jsp?arg1=aaa"/>
<forward name="f2" path="/f2.jsp?arg1=aaa"/>
</action>
public class UserAction extends Action {
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
throws Exception
{
switch
case 1: return actionMapping.findForward("f1");
case 2: return actionMapping.findForward("f2");
}
}
struts-config:
<action path="/aaa" type="UserAction" name="aaaForm" validate="false">
<forward name="f1" path="/f1.jsp?arg1=aaa"/>
<forward name="f2" path="/f2.jsp?arg1=aaa"/>
</action>
解决方案 »
- ssh开发的查询系统,查询7、8次就变慢,也没有出错信息,为什么?
- 关于工作流
- 截取ip地址前三段 jstl
- 用axis1.4的attachment来做文件传输,.NET客户端该怎么做?接口怎么定义?
- 在表格中删除数据
- 谁用过规则引擎. Drools engine ..万分火急
- jsp下载文件的问题
- JDBC里面PreparedStatement类的构造方法里面的参数IN是什么意思?怎么用?
- oracle中jdbc怎样写?,是oracle.jdbc.OracleDriver?
- 想买个手机学习j2me,请问,什么手机学习起来比较好呢?
- 在web容器中是哪个类实现了HttpServletRequest这个接口
- struts 运行出错
public class UserAction extends Action {
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
throws Exception {
......
......
我现在想根据我的业务的返回值返回不同的URL,而且URL里面还包含参数,格式可能为"XXX/ABC.htm?name=" + name;
然后将上面的这个动态拼出来URL来返回。而不仅仅根据结果返回 secuess 或者 error 什么的。
可能我还没说明白,我是根据我的业务来返回不同URL的,我会在这个程序里对数据库进行查询。
String url = "XXX/ABC.htm?name=" + name;//name 是我从数据库中动态查询出来的
//而上面哥们告诉我的方法是把url写死在配置文件里面的,这样我的所有name值就只能固定了,不能动态了。
return actionMapping.findForward("success");
}
}
变化的只有name吧??你跳转的网页就一个....干嘛要这样传参数name啊?
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
throws Exception {
......
......
String url = "XXX/ABC.htm"
httpServletRequest.setAttribute("name", name);
return actionMapping.findForward("success");
}
}
or write forward method and invoke itgive 分