这是我跑struts2的第一个例子,跑的也够郁闷的,这个问题烦了我几个钟。。。

2011-5-10 10:10:17 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Could not find action or result
No result defined for action com.augur.action.LoginAction and result success
 at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:364)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266)
 at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
 at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
 at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:252)
 atorg.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
 at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
 at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:122)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
 at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
 at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
 at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
 at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
 at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:179)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
 at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
 at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
 at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:235)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
 at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:89)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
 at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:130)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
 at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
 at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:126)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
 at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:138)
 at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
 at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:165)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
 at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
 at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:179)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
 at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:176)
 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
 at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
 at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
 at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
 at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:864)
 at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
 at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1665)
 at java.lang.Thread.run(Thread.java:662)

刚开始的login.jsp页面代码如下

<%@ page language="java" contentType="text/html; charset=gbk"
    pageEncoding="gbk"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gbk">
    <title>My JSP 'index.jsp' starting page</title>
  </head>
  
  <body>
    <form action="login.action" method="post">
        <table align="center">
            <caption>用户登录></caption>
            <tr>
                <td>用户名:<input type="text" name="username"/></td>
            </tr>
            <tr>
                <td>密&nbsp;&nbsp;码:<input type="text" name="password" /></td>
            </tr>
            <tr align="center">
                <td colspan="2"><input type="submit" value="登录" name="submit"/><input type="reset" value="重置"name="reset"/></td>
            </tr>
        </table>
    </form>
  </body>
</html>

LoginAction.java的代码如下

package com.augur.action;

public class LoginAction
{
    private String username;
    private String password;
    
    
    public String getUsername() {
        return username;
    }

public void setUsername(String username) {
        this.username = username;
    }

public String getPassword() {
        return password;
    }

public void setPassword(String password) {
        this.password = password;
    }

public String execute() throws Exception
    {
        if("1".equals(getUsername()) && "1".equals(getPassword()))
        {
            System.out.println("验证通过。。。");
            return "success";
        }
        else
        {
            System.out.println("验证失败....");
            return "failure";
        }
    }
}

struts.xml文件如下

<?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>
        
        <package name="struts2" extends="struts-default">
            <action name="login" class="com.augur.action.LoginAction">
                <result name="success">/welcome.jsp</result>
                <result name="failure">/error.jsp</result>
            </action>
        </package>
    </struts>

这个原因找了很久,网上说的原因也一大堆,关于格式转换错误的我觉得都不可能,这是很简单的一个例子。全都是String 类型的,压根可能性很低。试了好几个方法都不行。头大了几个钟。后面网上看到了login.jsp页面里面form的action属性的login.action和struts的action标签的name属性要对应,并且login的头字母要大写,也就是login.jsp里面form的action属性要改为Login.action,而struts.xml文件里面的action的name 也要对应的改为Login,发现这个错误真的很低级。当然造成这个错误可能也有其他原因。这只是其中之一。

 
 原文地址:http://blog.chinaunix.net/uid-9554081-id-2000842.html

Struts 2.x No result defined for action 异常的更多相关文章

  1. SSH配置struts校验发生No result defined for action actions.AdminLoginAction and result input

    配置struts校验发生No result defined for action actions.AdminLoginAction and result input,但是登录,success.jsp, ...

  2. struts异常:No result defined for action

    问题描述: No result defined for action com.freedom.funitureCityPSIMS.controller.login.CheckAction and re ...

  3. No result defined for action com.lk.IndexAction and result success

    意图访问一个 /es/index.action 竟然出现: [SAE ] ERROR [05-11 13:54:32] [http-80-5] com.opensymphony.xwork2.util ...

  4. Struts2问题,已解决No result defined for action and result input

    struts2.1.8 必须在struts.xml中配置namespace属性 如果你在2.0中一切OK,但是在2.1中确出现了No result defined for action的异常,就是在因 ...

  5. validators配置要点及No result defined for action报错解决方案

    在做JavaEE SSH项目时,接触到validators验证. 需要了解validators配置,或者遇到No result defined for action 这个错误时,可查阅本文得到有效解决 ...

  6. No result defined for action com.nynt.action.ManageAction and result input问题

    No result defined for action com.nynt.action.ManageAction and result input 问题原因: 1). 在action类中定义的一个r ...

  7. Messages: No result defined for action cn.itcast.oa.test.TestAction and result SUCCESS

    Struts Problem Report Struts has detected an unhandled exception: Messages: No result defined for ac ...

  8. No result defined for action and result input

    今天在编程的时候,我遇到了No result defined for action and result input的错误,这个错误想必大家都有遇到过吧,我今天发了很长时间弄这个错误,我以为我的Act ...

  9. Struts2.3动态调用报 No result defined for action 错误

    struts 2.3.16  採用动态调用发现不工作报404 not found,网上查找原因: 1.由于:struts2中默认不同意使用DMI 所以:须要在配置文件里打开: <constant ...

随机推荐

  1. Uva674 完全背包求方案数

    记忆化搜索.注意输入n的位置,否则Tle. dp[i][j]表示用前j种硬币组成i分钱时的种类数 那么状态转移方程是:dp[i][j]+=DP(i-k*v[j],j-1) #include<io ...

  2. junit单元测试中私有方法测试

    1.单元测试可以对系统逻辑进行每个单元模块的测试. 2.单元测试也可以作为回归测试的依据,可以避免升级完善功能时引入问题. 3.单元测试要求将代码写的更清晰,更易于测试. 4.有时单元测试需要测试私有 ...

  3. maven自建仓库 Return code : 405

    maven自建仓库jar包上传: jar包上传可以采用在自建仓库上系统上传以及通过配置maven setting.xml以及pom.xml上传. maven通过配置上传需要用户名密码以及maven仓库 ...

  4. 微软开放WP开发者回复用户应用评论功能

    1   4月18日,据The NextWeb网站报道,微软今天公布了一项新的开发者试点项目:回复Windows Phone应用评论.该公司表示,它们将在本周推出这项功能,不过目前仅对部分开发者开放. ...

  5. 后缀数组 POJ 1743 Musical Theme

    题目链接 题意:给定n个数字,求超过5个数字的,最长的,变化相同的,不相交的重复子串 分析:男人8题中的一题!数列相邻两项做差,形成新数列,即求数列中的最长重复子串(不可相交). 后缀数组+二分答案. ...

  6. sql 、linq、lambda 总结

    LINQ的书写格式如下: from 临时变量 in 集合对象或数据库对象 where 条件表达式 [order by条件] select 临时变量中被查询的值 [group by 条件] Lambda ...

  7. BZOJ3424 : Poi2013 Multidrink

    详细做法以及证明请看论文<Hamiltonian paths in the square of a tree>. 首先将1到n的路径提取出来,作为主干. 定义毛毛虫为去掉叶子之后只有一条单 ...

  8. BZOJ2164 : 采矿

    树链剖分+线段树,每个节点维护以下信息: (1)单独在某个点分配$i$个人的最大收益.可以$O(m)$合并. (2)分配$i$个人的最大收益.可以用$O(m^2)$合并. 时间复杂度$O(c(m^2\ ...

  9. BZOJ 1468 & 点分治

    题意: 带权树,求距离小于k的点对数目. SOL: 参考http://blog.csdn.net/jiangshibiao/article/details/25738041解决了题意问题... 代码是 ...

  10. 2001. Counting Sheep

      After a long night of coding, Charles Pearson Peterson is having trouble sleeping. This is not onl ...