这个name默认有success、input、error、login、none。但是我想问可以自定义吗?比如定义成<result name="ok">定义成ok。
如果可以,那我为什么我的代码运行报错呢,但是改为success又可以运行了。报错:HTTP Status 404 - No result defined for action com.wr.action.LoginAction and result success
action代码:public String isLogin() {
HttpServletRequest request = null;

User u = new User();
u.setName(name);
u.setPwd(pwd);
u = loginService.isLogin(u);
if(u!=null) {
System.out.println("name"+name);
request.getSession().setAttribute("user", u);
return "ok";
}
     return ERROR;
}
struts.xml代码:<action name="login_isLogin" class="com.wr.action.LoginAction" >
      <result name="ok">success.jsp</result>
      <result name="error">error.jsp</result>     
    </action>
jsp代码<form action="login_isLogin.action" method="post">
      name:<input type="text" name="name"/><br>
      pwd:<input type="password" name="pwd"/>
      <input type="submit" value="登录"/><input type="reset" value="重置"/>
     </form>

解决方案 »

  1.   

    完全没问题啊,只是你的<result name="error">error.jsp</result>     有问题应该是<result name="error">/error.jsp</result>     
      

  2.   

    return ERROR 改成 return "error"; 试试
      

  3.   

    不肯能,肯定是你哪里写错了,HTTP Status 404 - No result defined for action com.wr.action.LoginAction and result success
    这句话意思是说 没有找到 result=success的配置<action name="login_isLogin" class="com.wr.action.LoginAction" >
    你的这个 配置 表示 默认调用execute,但是你贴出来的根本就不是,isLogin也没有配置动态方法, 所以你前面的测试全是execute()方法
      

  4.   

    <action name="login_isLogin" class="com.wr.action.LoginAction" >
    改为:
    <action name="login_isLogin" class="com.wr.action.LoginAction" method=“login_isLogin” >