struts.xml
<package name="default" extends="struts-default">
 
<action name="login" class="com.capsa.web.struts.action.LoginAction">
 <result name="login">/main.jsp</result>
 <result name="false">/login.jsp</result>
 </action>
 
<action name="queryAllUsers" class="com.capsa.web.struts.action.QueryAllUsers">
 <result name="success">/umain.jsp</result>
 <result name="input">/login.jsp</result>
 </action>

 
<action name="queryAllE" class="com.capsa.web.struts.action.QueryAllE">
 <result name="allE">/emain.jsp</result>
 <result name="false">/login.jsp</result>
 </action>
</package>QueryAllUsers类的代码
 
public String execute()
 {
 //String flag = "false";
 if(currentPage == null)
 {
 currentPage = "1";
 }
 //System.out.println("开始");
int totalRows = user1DAO.getAllUsersRows();
 System.out.println(totalRows);
 Pager pager = (new PagerService()).getPager(currentPage, pageWay, totalRows);
 System.out.println(pager);
 int pageSize = 10;
 pager.setPageSize(pageSize);
 System.out.println(pager.getPageSize());
 int startRow = pager.getStartRow();
 System.out.println(startRow);
 int endRow = startRow + pageSize; //ActionContext actionContext = ActionContext.getContext();
 //actionContext.put("currentPage", pager.getCurrentPage()); List resultsList = user1DAO.getAllUsers();
 //System.out.println("开始6");
 List ulist = new ArrayList<User1>();
 User1 user = new User1();
 //System.out.println("开始7");
 for(int i=startRow; i<endRow; i++)
 {
 user = (User1)resultsList.get(i);
 System.out.println(user.getEmployeeId());
 ulist.add(user);
 //System.out.println("开始9");
 }
 //System.out.println("开10"); if(ulist.size()>0){
 return SUCCESS;
 }else{
 return INPUT;
 }
 //actionContext.put("list", list);
 //System.out.println(flag);
 //return flag;
 }QueryAllUsers这个类你的代码我已经测试过,可以正常返回success。但是跳转的页面却不是umain.jsp。而是login.jsp。奇怪的是,当我修改了一下变成
 
<action name="queryAllUsers" class="com.capsa.web.struts.action.QueryAllUsers">
 <result name="success">/umain.jsp</result>
 <result name="input">/login.jsp</result>
 </action>
 跳转的页面居然还是login.jsp。
 当我把请教高手给怎么办?在线等,全给分。
ps:第一个loginaction可以成功跳转

解决方案 »

  1.   

    if(ulist.size()>0){
     return SUCCESS;
     }else{
     return INPUT;
     }
    改成
    if(ulist.size()>0){
     return "success";
     }else{
     return INPUT;
     }试试
      

  2.   

    SUCCESS跳转可以在struts的result里不用加SUCCESS,默认的。楼主你的package应该添加namespace="/",提供你的域名访问地址,可以这样改了试一下:<package name="default" extends="struts-default" namespace="/">
    <action name="queryAllUsers" class="com.capsa.web.struts.action.QueryAllUsers">
    <result>/umain.jsp</result>
    <result name="input">/login.jsp</result>
    </action>
    </package>
      

  3.   

    <TABLE cellSpacing=0 cellPadding=0 width=749 border=0>
    <TBODY>
    <TR vAlign=top>
    <TD width=173 bgColor=#c9d3e9 rowSpan=2>
    <TABLE cellSpacing=0 cellPadding=0 width=173 border=0>
    <TBODY>
    <TR>
    <TD width=11 height="29" bgColor=#2650a6>
    <IMG height=1 src="images/blank.gif" width=1 border=0>
    <img src="images/Arrow1.gif" width="23" height="23">
    </TD>
    <TD width=165 height="29" bgColor=#7691c7>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <A class=nav href="eadd.jsp">添加设备</A>
    </TD>
    </TR>
    <TR>
    <TD bgColor=#ffffff colSpan=2>
    <IMG height=1 src="images/blank.gif" width=1 border=0>
    </TD>
    </TR>
    <TR>
    <TD width=11 bgColor=#2650a6>
    <IMG height=1 src="images/blank.gif" width=1 border=0>
    <img src="images/Arrow1.gif" width="23" height="23">
    </TD>
    <TD width=165 height="29" bgColor=#7691c7>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <A class=nav href="eadd.jsp">台账管理</A>
    </TD>
    </TR>

    <TR> </TR>
    <TR>
    <TD bgColor=#ffffff colSpan=2>
    <IMG height=1 src="images/blank.gif" width=1 border=0>
    </TD>
    </TR>
    <TR>
    <TD width=11 bgColor=#2650a6>
    <IMG height=1 src="images/blank.gif" width=1 border=0>
    <img src="images/Arrow1.gif" width="23" height="23">
    </TD>
    <TD width=165 height="29" bgColor=#7691c7>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <A class=nav href="tadd.jsp">添加记录</A>
    </TD>
    </TR>
    <TR>
    <TD bgColor=#ffffff colSpan=2>
    <IMG height=1 src="images/blank.gif" width=1 border=0>
    </TD>
    </TR>
    <TR>
    <TD width=11 bgColor=#2650a6>
    <IMG height=1 src="images/blank.gif" width=1 border=0>
    <img src="images/Arrow1.gif" width="23" height="23">
    </TD>
    <TD width=165 height="29" bgColor=#7691c7>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <A class=nav href="tmain.jsp">记录管理</A>
    </TD>
    </TR> <TR>
    <TD bgColor=#ffffff colSpan=2>
    <IMG height=1 src="images/blank.gif" width=1 border=0>
    </TD>
    </TR>
    <TR>
    <TD width=11 bgColor=#2650a6>
    <IMG height=1 src="images/blank.gif" width=1 border=0>
    <img src="images/Arrow1.gif" width="23" height="23">
    </TD>
    <TD width=165 height="29" bgColor=#7691c7>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <A class=nav href="bmain.jsp">报表管理</A>
    </TD>
    </TR>
    <TR>
    <TD bgColor=#ffffff colSpan=2>
    <IMG height=1 src="images/blank.gif" width=1 border=0>
    </TD>
    </TR>
    <TR>
    <TD width=11 bgColor=#2650a6>
    <IMG height=1 src="images/blank.gif" width=1 border=0>
    <img src="images/Arrow1.gif" width="23" height="23">
    </TD>
    <TD width=165 height="29" bgColor=#7691c7>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <A class=nav href="uadd.jsp">添加用户</A>
    </TD>
    </TR>
    <TR>
    <TD bgColor=#ffffff colSpan=2>
    <IMG height=1 src="images/blank.gif" width=1 border=0>
    </TD>
    </TR>
    <TR>
    <TD width=11 bgColor=#2650a6>
    <IMG height=1 src="images/blank.gif" width=1 border=0>
    <img src="images/Arrow1.gif" width="23" height="23">
    </TD>
    <TD width=165 height="29" bgColor=#7691c7>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <A class=nav href=<s:action name="queryAllUsers"></s:action>>系统管理</A>
    <!--A class=nav href="queryAllUsers.action">系统管理</A>-->
    </TD>
    </TR>