+ -
当前位置:首页 → 问答吧 → 急需解答action的有关写法问题

急需解答action的有关写法问题

时间:2011-11-26

来源:互联网

在struts框架:有两个页面first.jsp和second.jsp,在first页面中仅有一个按钮,点击后会跳转到second页面,那action怎么写?

作者: Tiantong_47   发布时间: 2011-11-26

如果是struts2.x,在excute里面写return "second"。在struts配置文件中加上second参数,指向second.jsp路径即可

作者: hanjiaming   发布时间: 2011-11-26

我这样写过了,跳转不过去??

作者: Tiantong_47   发布时间: 2011-11-26

1楼的方法是完全可行的,楼主需要耐心,一步步的调试,有可能你action都无调用呢

作者: zyz1985   发布时间: 2011-11-26

可能是struts配置文件那里出错了吧,楼主耐心查看!

作者: Qconzhongxiao   发布时间: 2011-11-26

配置:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
  <struts>
   
  <!-- Action必须放在指定的包名空间中-->
   
  <package name="struts2" extends="struts-default">
  <action name="first"
  class="net.hncu.action.FirstAction">
  <result name="second">/second.jsp</result>
  </action>
   
  </package>
  </struts>  
action怎么写呢? 这样写? 
  public String execute()throws Exception{
return "second";

作者: Tiantong_47   发布时间: 2011-11-26