在项目中调用一个action的方法的时候发生了一个错误,但是在catalina.out和配置的log4j都没有打印异常,后来在执行的action中加了logger.error("XXXXX"),也没有打印异常。

后来发现是struts2默认的有异常拦截器ExceptionMappingInterceptor,但是是禁用的,需要自己启用

                <interceptor-ref name="defaultStack">
<param name="exception.logEnabled">true</param>
<param name="exception.logLevel">ERROR</param>
</interceptor-ref>

自定义全局异常处理的显示的页面

        <global-results>
<result name="error">/public/error.jsp</result>
</global-results> <global-exception-mappings>
<exception-mapping result="error" exception="java.lang.Exception"></exception-mapping>
</global-exception-mappings>

在显示的页面/public/error.jsp也可以显示发生的异常信息

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div class="msgFalse" >
<dl>
<dt>操作失败</dt>
</dl> <s:property value="exception"/>
<s:property value="exceptionStack"/>
</div>
</body>
</html>

异常:No result defined for action XXXAction and result input

1.在action里面定义了某类型的变量,然后想通过struts的自动填装把post来的表单的数据转换,如果转换类型失败就出现此种错误

2.页面提交了同一个名字的参数多个

比如“”
username 123
username 123
permissions 123
info 31234
页面提交了了两个username ,而我的后台却只写了一个String username,这样同样会出错.

3.页面中用到的控件名称与后台Action中的属性名称不一致

这个很好理解,名称不匹配,Struts2是不会给Action中的属性赋值的

struts2没有打印日志原因和No result defined for action XXXAction and result input的更多相关文章

  1. Struts2报错:No result defined for action xxx and result input

    case如下: 1. 后台程序要升级, 修改了一些功能,但是没有修改或者添加action的参数. 2. 数据库需要升级,执行了一些sql,修改过action的值. 3. 当修改某个已经存在的记录,然后 ...

  2. struts2 No result defined for action XXX and result input

    这种错误的原因一般是页面的属性和action里的属性个数.名称.类型不一致造成的 困扰了我一下午的问题,原来是表单中有两个input-text的name属性重复了,然后接受参数的时候就出现了这个错误 ...

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

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

  4. [Struts2] No result defined for action ... and result input &amp; Invalid field value for field ...

    "No result defined for action ... and result input"错误一般发生在Struts2的拦截器拦截时遇到了问题时.Struts2会将跳转 ...

  5. 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的异常,就是在因 ...

  6. 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 ...

  7. Struts 2.x No result defined for action 异常

      这是我跑struts2的第一个例子,跑的也够郁闷的,这个问题烦了我几个钟... 2011-5-10 10:10:17 com.opensymphony.xwork2.util.logging.co ...

  8. HTTP Status 404 - No result defined for action com.hebky.oa.classEntity.action.EntitysAction and result input

    在开发中总遇到这个问题,No result defined for action:原因:Action中的属性值为空的时候,Struts2的默认拦截器会报错,但是又找不到input的Result,不能够 ...

  9. no result defined for action

    1.no result defined for action .......and result input    或者 no result defined for action .......and ...

随机推荐

  1. 【VS开发】CTime和CTimeSpan使用

    此文就用一个程序表示,相信只要是学过C语言的都能看得懂的. [html] view plain copy print? // CTimeTest.cpp : Defines the entry poi ...

  2. ip速度检测与云主机|VPS的抉择:bandwagonhost digitalocean hostWind Vultr Linode

    最近的梯子断了,网站又被注销了.又到了挑vps的时间了.其实, 这些东西,烦死人了.挺浪费生命的. 首先速度测试, MTR测试 网站速度测试 17CE. http://tool.chinaz.com/ ...

  3. 分享个昨天学的,sqlserver查表的所有列的列名,类型,长度的sql

     select a.name as 列名, a.length as 长度,b.name as 类型 from syscolumns a left join systypes b on a.xtype  ...

  4. shell作业01

    1.判断/etc/inittab文件是否大于100行,如果大于,则显示”/etc/inittab is a big file.”否者显示”/etc/inittab is a small file.” ...

  5. 【模板】SPFA(不完全详解)

    一种最短路求法(个人觉得比DIJKSTRA好用) 用于有向图. 大概思路:从根节点开始,枚举每一个点,同时更新他们所联通的点的最短路径,如果路径被更新,则把这个点入队,一直重复这个操作直到队伍为空为止 ...

  6. 用纯 CSS 创作一个在容器中反弹的小球

    效果预览 在线演示 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/jKVbyE 可交互视频教 ...

  7. MVCC实现机制

    1. MVCC简介 1.1 什么是MVCC MVCC(Multiversion concurrency control )是一种多版本并发控制机制. 1.2 MVCC是为了解决什么问题? 并发访问(读 ...

  8. JS基础_js编写位置

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  9. 用java语言(文件和文件流知识点)实现图片的拷贝,从d盘拷贝到e盘

    /** * 实现图片的拷贝\ * 注意:用的是文件字节流 */ package com.test4; import java.io.*; public class Demo12_4 { /** * @ ...

  10. 07 Python之字典和集合

    1. 什么是字典 字典是用{}表示,以key:value的形式来保存数据的,其查找效率比较高 坑: 字典存储数据时是用哈希值来存储的,算法不能变(python的) 数据必须是可哈希的(不可变的),字典 ...