当前位置:   article > 正文

Struts2 异常处理机制_struts2的全局异常处理

struts2的全局异常处理
原创

Struts2 异常处理机制

任何成熟的MVC框架都应该提供成就的异常处理机制,Strut2也不例外。Struts2提供了一种声明式的异常处理方式,Struts2也是通过配置的拦截器来实现异常处理机制的。

一异常处理机制

1、配置

Struts2的异常处理机制是:通过在struts.xml文件中配置﹤exception-mapping …﹥元素完成的,配置该元素时,需要指定两个属性:

exception:此属性指定该异常映射所设置的异常类型。

result:此属性指定Action出现该异常时,系统转入result属性所指向的结果。

异常映射也分为两种:

局部异常映射:<exception-mapping…>元素作为<action…>元素的子元素配置。

全局异常映射:<exception-mapping…>元素作为<global-exception-mappings>元素的子元素配置。


2、输出异常信息

使用Struts2的标签来输出异常信息:

<s:property value="exception.message"/>:输出异常对象本身。

<s:property value="exceptionStack"/>: 输出异常堆栈信息。

利用struts2的异常处理机制和拦截器机制,可以很方便的实现异常处理功能,你不再需要在Action中捕获异常,并抛出相关的异常了,这些都交给拦截器来帮你做了。


二、应用实例

1、配置struts.xml

1.  在 struts.xml 文件中,声明全局异常映射,以及对应的全局异常转发如下所示:

<global-results>

           <result name="error">/admin/error/ErrDisplay.ftl</result>

       </global-results>

      

       <global-exception-mappings>

           <exception-mapping result="error"

              exception="org.basis.common.exception.SystemException"></exception-mapping>

       </global-exception-mappings>


2、异常处理类

SystemException是异常处理类,代码如下所示:

package org.basis.common.exception;

 

public class SystemException extends RuntimeException {

 

    private static final long serialVersionUID = 1L;

 

    public SystemException(String frdMessage) {

       super(createFriendlyErrMsg(frdMessage));

    }

 

    public SystemException(Throwable throwable){

       super(throwable);

    }

 

    public SystemException(Throwable throwable, String frdMessage){

       super(throwable);

    }

 

   

    private static String createFriendlyErrMsg(String msgBody) {

       String prefixStr = "抱歉。";

       String suffixStr = "请稍后再试或与管理员联系!";

       StringBuffer friendlyErrMsg = new StringBuffer();

       friendlyErrMsg.append(prefixStr);

       friendlyErrMsg.append(msgBody);

       friendlyErrMsg.append(suffixStr);

       return friendlyErrMsg.toString();

    }

 

}

3、全局异常处理页面

在系统的/WebRoot/common/global/目录下,新建一个全局的异常处一页面errorPage.jsp。这个页面很简单。

JAVA代码:errorPage.jsp

<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>

<%@ page isErrorPage="true"%>

<%@ taglib prefix="s" uri="/struts-tags" %>

<%

    response.setHeader("Cache-Control","no-cache");

    response.setHeader("Cache-Control","no-store");

    response.setDateHeader("Expires",0);

    response.setHeader("Pragma","no-cache");

%>

<html>

<head>

<script language="javascript">

function showContent(){

    if(document.getElementByIdx_x("errorMessage").style.display == 'block'){

       document.getElementByIdx_x("errorMessage").style.display = 'none';

    }else{

       document.getElementByIdx_x("errorMessage").style.display = 'block';

    }

}

</script>

</head>

<body scroll="auto">

<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">

<tr>

    <td align="center" class="bg" valign="top">

       <table width="100%" border="0" cellspacing="0" cellpadding="0" style="table-layout:fixed;word-break:break-all;">

           <tr>

              <td align="center" width="100%" height="80">

                  <img src="${pageContext.request.contextPath}/common/images/basis/systemException.gif" border="0" align="absmiddle">   <s:property value="exception.message" />                   

              </td>

           </tr>

           <tr>

              <td height="30" align="center">

                  <a href="#" οnclick="javascript:history.go(-1);"><s:text name="global.return"/></a>   

                  <a href="#" οnclick="javascript:showContent();">查看详细信息</a>

              </td>

           </tr>

           <tr>

              <td align="left" valign="top">

                  <!-- 异常堆栈信息(开发人员用) -->

                  <div style="display:none;" id="errorMessage">

                  <pre>   <s:property value="exceptionStack" /></pre>

                  </div>

              </td>

           </tr>

       </table>

    </td>

</tr>

</table>

</body>

</html>


4、自定义异常拦截器

在这里,应用自定义的异常拦截器,在拦截器中,捕获常见的异常,并以友好异常信息抛出,相关代码如下所示:

JAVA代码:ExceptionInterceptor.java

package org.basis.struts.interceptor;

 

import java.io.IOException;

import java.sql.SQLException;

import org.basis.common.exception.SystemException;

import org.springframework.dao.DataAccessException;

import com.opensymphony.xwork2.ActionInvocation;

import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

 

@SuppressWarnings("serial")

public class ExceptionInterceptor extends AbstractInterceptor {

 

    @SuppressWarnings("unchecked")

    public String intercept(ActionInvocation actionInvocation) throws Exception {

       String result = "";

       try {

           result = actionInvocation.invoke();

       } catch (DataAccessException ex) {

           throw new SystemException("数据库操作失败!");

       } catch (NullPointerException ex) {

           throw new SystemException("空指针,调用了未经初始化或者是不存在的对象!");

       } catch (IOException ex) {

           throw new SystemException("IO读写异常!");

       } catch (ClassNotFoundException ex) {

           throw new SystemException("指定的类不存在!");

       } catch (ArithmeticException ex) {

           throw new SystemException("数学运算异常!");

       } catch (ArrayIndexOutOfBoundsException ex) {

           throw new SystemException("数组下标越界!");

       } catch (IllegalArgumentException ex) {

           throw new SystemException("调用方法的参数错误!");

       } catch (ClassCastException ex) {

           throw new SystemException("类型强制转换错误!");

       } catch (SecurityException ex) {

           throw new SystemException("违背安全原则异常!");

       } catch (SQLException ex) {

           throw new SystemException("操作数据库异常!");

       } catch (NoSuchMethodError ex) {

           throw new SystemException("调用了未定义的方法!");

       } catch (InternalError ex) {

           throw new SystemException("Java虚拟机发生了内部错误!");

       } catch (Exception ex) {

           throw new SystemException("程序内部错误,操作失败!");

       }

       return result;

    }

}


5、配置异常拦截器

配置这个拦截器,代码如下:

struts.xml文件局部:

<interceptors>

           <interceptor name="checkLogin" class="org.basis.struts.interceptor.CheckLoginInterceptor" />

           <interceptor name="checkException" class="org.basis.struts.interceptor.ExceptionInterceptor" />

           <!-- 定义一个拦截器栈 -->

           <interceptor-stack name="mydefault">

              <interceptor-ref name="defaultStack" />

              <interceptor-ref name="checkException" />

           </interceptor-stack>

       </interceptors>

       <default-interceptor-ref name="mydefault" />

 

       <global-results>

           <result name="error">/common/global/errorPage.jsp</result>

       </global-results>

      

       <global-exception-mappings>

           <exception-mapping result="error"

              exception="org.basis.common.exception.SystemException"></exception-mapping>

       </global-exception-mappings>

经过这样处理,Struts2做异常处理还是比较方便的了。


6、应用实际效果

下面我们修改一下前面国际华的那个Action,让它抛一个错误。

package demo.struts2.action;

 

import java.util.ArrayList;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;

 

public class MessageAction extends ActionSupport {

 

    public String execute() throws Exception {

       // getText(String) string为key

       String str1 = getText("label.helloWorld");

       System.out.println(str1);

       // 带参数的

       String str2 = getText("label.hello", new String[] { "fjf" });

       System.out.println(str2);

 

       // 与上一种实现一样

       List l = new ArrayList();

       l.add("callan");

       String str3 = getText("label.hello", l);

       System.out.println(str3);

      

       String str4 = getText("userName.required");

       System.out.println(str4);

      

       int i = 1/0;

 

       return SUCCESS;

    }

}

我们知道,做除法的时候,除数不能为零,int i = 1/0;这里应该抛出错误,实际运行一下这个Action,系统提示异常,如下图所示:


文章最后发布于: 2012-05-10 15:42:28
        <div class="hide-article-box hide-article-pos text-center">
        <a class="btn-readmore" data-report-view="{&quot;mod&quot;:&quot;popu_376&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/tianyulinger3344/article/details/7554226&quot;,&quot;strategy&quot;:&quot;readmore&quot;}" data-report-click="{&quot;mod&quot;:&quot;popu_376&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/tianyulinger3344/article/details/7554226&quot;,&quot;strategy&quot;:&quot;readmore&quot;}">
            展开阅读全文
            <svg class="icon chevrondown" aria-hidden="true">
                <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#csdnc-chevrondown"></use>
            </svg>
        </a>
    </div>
            <!--打赏开始-->
                        <div class="reward-user-box">
                <span class="reward-word" style="color:#B4B4B4 !important">有 <span class="num">0</span> 个人打赏</span>
                                </div>
                    <!--打赏结束-->
        <div class="recommend-box"><div class="recommend-item-box type_blog clearfix" data-report-view="{&quot;mod&quot;:&quot;popu_387&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/u011159417/article/details/72782627&quot;,&quot;strategy&quot;:&quot;BlogCommendFromMachineLearnPai2&quot;,&quot;index&quot;:&quot;0&quot;}" data-report-click="{&quot;mod&quot;:&quot;popu_387&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/u011159417/article/details/72782627&quot;,&quot;strategy&quot;:&quot;BlogCommendFromMachineLearnPai2&quot;,&quot;index&quot;:&quot;0&quot;}">
<div class="content" style="width: 712px;">
	<a href="https://blog.csdn.net/u011159417/article/details/72782627" target="_blank" rel="noopener" title="Struts2声明式异常处理">
	<h4 class="text-truncate oneline" style="width: 552px;">
			<em>Struts</em><em>2</em>声明式<em>异常</em><em>处理</em>		</h4>
	<div class="info-box d-flex align-content-center">
		<p class="date-and-readNum oneline">
			<span class="date hover-show">05-27</span>
			<span class="read-num hover-hide">
				阅读数 
				1550</span>
			</p>
		</div>
	</a>
	<p class="content" style="width: 712px;">
		<a href="https://blog.csdn.net/u011159417/article/details/72782627" target="_blank" rel="noopener" title="Struts2声明式异常处理">
			<span class="desc oneline">在使用框架之前我们的程序中遇到异常,都是使用try{…}catch{…}手动捕获解决,或者使用throwsException将异常抛给别人去解决。在struts2框架中,异常的解决方法,更方便了,只要...</span>
		</a>
		<span class="blog_title_box oneline ">
								<span class="type-show type-show-blog type-show-after">博文</span>
										<a target="_blank" rel="noopener" href="https://blog.csdn.net/u011159417">来自:	<span class="blog_title"> 红桃峰峰 的博客</span></a>
											</span>
	</p>
</div>
</div>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
还能输入1000个字符
<div class="comment-list-container">
	<a id="comments"></a>
	<div class="comment-list-box">
	</div>
	<div id="commentPage" class="pagination-box d-none"></div>
	<div class="opt-box text-center">
		<div class="btn btn-sm btn-link-blue" id="btnMoreComment"></div>
	</div>
</div>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
struts2中的异常映射处理机制

04-14 阅读数 1947

struts2中的全局异常映射和局部异常映射 博文 来自: VipMao的博客

<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_59" data-pid="59"><script type="text/javascript">
(function() {
    var s = "_" + Math.random().toString(36).slice(2);
    document.write('<div style="" id="' + s + '"></div>');
    (window.slotbydup = window.slotbydup || []).push({
        id: "u3491668",
        container:  s
    });
})();
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

Struts2异常处理机制 - 想念的专栏 - CSDN博客

9-30

Struts2异常处理 - 寻找心的旅程 - CSDN博客

10-1

<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_60" data-pid="60"><iframe src="https://adaccount.csdn.net/#/preview/645?m=biLLbiticALpQQnnHiLbbcDbyLtHciAbnDEmtLQJSHXQiLHbXfvAHnQtWpiciXEDvEnDAptDnnnAAiSpfDHJiDtpQtSiptEnEJiQ&amp;k=" frameborder="0" width="100%" height="75px" scrolling="no"></iframe><img class="pre-img-lasy" data-src="https://kunyu.csdn.net/1.png?d=2&amp;k=&amp;m=biLLbiticALpQQnnHiLbbcDbyLtHciAbnDEmtLQJSHXQiLHbXfvAHnQtWpiciXEDvEnDAptDnnnAAiSpfDHJiDtpQtSiptEnEJiQ"></div></div>
  • 1
Struts2异常处理机制 - u011004598的专栏 - CSDN博客

11-25

Struts2异常处理机制 - E01014165的专栏 - CSDN博客

10-17

		<div class="recommend-item-box blog-expert-recommend-box" style="display: block;">
		<div class="d-flex">
			<div class="blog-expert-recommend">
				<div class="blog-expert">
					<div class="blog-expert-flexbox" data-report-view="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/tianyulinger3344/article/details/7554226&quot;}"><div class="blog-expert-item"><div class="blog-expert-info-box"><div class="blog-expert-img-box" data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/tianyulinger3344/article/details/7554226&quot;}"><a href="https://blog.csdn.net/u011159417" target="_blank"><img src="https://profile.csdnimg.cn/5/6/6/3_u011159417" username="u011159417" alt="关注:日拱一卒" title="关注:日拱一卒"></a><span data-report-click="{&quot;mod&quot;:&quot;popu_710&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/tianyulinger3344/article/details/7554226&quot;}"><span class="blog-expert-button-follow btn-red-follow" data-name="u011159417" data-nick="关注:日拱一卒">关注</span></span></div><div class="info"><span data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/tianyulinger3344/article/details/7554226&quot;}"><a href="https://blog.csdn.net/u011159417" target="_blank"><h5 class="oneline" title="关注:日拱一卒">关注:日拱一卒</h5></a></span>  <p></p><p class="article-num" title="230篇文章"> 230篇文章</p><p class="article-num" title="排名:7000+"> 排名:7000+</p><p></p></div></div></div><div class="blog-expert-item"><div class="blog-expert-info-box"><div class="blog-expert-img-box" data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/tianyulinger3344/article/details/7554226&quot;}"><a href="https://blog.csdn.net/VipMao" target="_blank"><img src="https://profile.csdnimg.cn/7/7/9/3_vipmao" username="VipMao" alt="VipMao" title="VipMao"></a><span data-report-click="{&quot;mod&quot;:&quot;popu_710&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/tianyulinger3344/article/details/7554226&quot;}"><span class="blog-expert-button-follow btn-red-follow" data-name="VipMao" data-nick="VipMao">关注</span></span></div><div class="info"><span data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/tianyulinger3344/article/details/7554226&quot;}"><a href="https://blog.csdn.net/VipMao" target="_blank"><h5 class="oneline" title="VipMao">VipMao</h5></a></span>  <p></p><p class="article-num" title="94篇文章"> 94篇文章</p><p class="article-num" title="排名:千里之外"> 排名:千里之外</p><p></p></div></div></div><div class="blog-expert-item"><div class="blog-expert-info-box"><div class="blog-expert-img-box" data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/tianyulinger3344/article/details/7554226&quot;}"><a href="https://blog.csdn.net/cyywxy" target="_blank"><img src="https://profile.csdnimg.cn/C/F/7/3_cyywxy" username="cyywxy" alt="cyywxy" title="cyywxy"></a><span data-report-click="{&quot;mod&quot;:&quot;popu_710&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/tianyulinger3344/article/details/7554226&quot;}"><span class="blog-expert-button-follow btn-red-follow" data-name="cyywxy" data-nick="cyywxy">关注</span></span></div><div class="info"><span data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/tianyulinger3344/article/details/7554226&quot;}"><a href="https://blog.csdn.net/cyywxy" target="_blank"><h5 class="oneline" title="cyywxy">cyywxy</h5></a></span>  <p></p><p class="article-num" title="131篇文章"> 131篇文章</p><p class="article-num" title="排名:千里之外"> 排名:千里之外</p><p></p></div></div></div><div class="blog-expert-item"><div class="blog-expert-info-box"><div class="blog-expert-img-box" data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/tianyulinger3344/article/details/7554226&quot;}"><a href="https://blog.csdn.net/kaixuanfeng2012" target="_blank"><img src="https://profile.csdnimg.cn/3/7/5/3_kaixuanfeng2012" username="kaixuanfeng2012" alt="凯炫风" title="凯炫风"></a><span data-report-click="{&quot;mod&quot;:&quot;popu_710&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/tianyulinger3344/article/details/7554226&quot;}"><span class="blog-expert-button-follow btn-red-follow" data-name="kaixuanfeng2012" data-nick="凯炫风">关注</span></span></div><div class="info"><span data-report-click="{&quot;mod&quot;:&quot;popu_709&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/tianyulinger3344/article/details/7554226&quot;}"><a href="https://blog.csdn.net/kaixuanfeng2012" target="_blank"><h5 class="oneline" title="凯炫风">凯炫风</h5></a></span>  <p></p><p class="article-num" title="102篇文章"> 102篇文章</p><p class="article-num" title="排名:千里之外"> 排名:千里之外</p><p></p></div></div></div></div>
				</div>
			</div>
		</div>
	</div><div class="recommend-item-box baiduSearch recommend-box-ident" data-report-view="{&quot;mod&quot;:&quot;popu_387&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/michael1112/article/details/71128832&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:&quot;5&quot;}" data-report-click="{&quot;mod&quot;:&quot;popu_387&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/michael1112/article/details/71128832&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:&quot;5&quot;}" data-track-view="{&quot;mod&quot;:&quot;popu_387&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/michael1112/article/details/71128832&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:4,&quot;extend1&quot;:&quot;_&quot;}" data-track-click="{&quot;mod&quot;:&quot;popu_387&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/michael1112/article/details/71128832&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:4,&quot;extend1&quot;:&quot;_&quot;}" data-flg="true">                <a href="https://blog.csdn.net/michael1112/article/details/71128832" target="_blank">              		<h4 class="text-truncate oneline" style="width: 626px;"><em>Struts</em><em>2</em> <em>异常</em><em>处理</em> - michael111<em>2</em>的专栏 - CSDN博客</h4>                  <div class="info-box d-flex align-content-center">                    <p>                      <span class="date">11-24</span>                    </p>                  </div>                </a>            	</div><div class="recommend-item-box baiduSearch recommend-box-ident" data-report-view="{&quot;mod&quot;:&quot;popu_387&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/collegeyuan/article/details/84764785&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:&quot;6&quot;}" data-report-click="{&quot;mod&quot;:&quot;popu_387&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/collegeyuan/article/details/84764785&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:&quot;6&quot;}" data-track-view="{&quot;mod&quot;:&quot;popu_387&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/collegeyuan/article/details/84764785&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:5,&quot;extend1&quot;:&quot;_&quot;}" data-track-click="{&quot;mod&quot;:&quot;popu_387&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/collegeyuan/article/details/84764785&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:5,&quot;extend1&quot;:&quot;_&quot;}" data-flg="true">                <a href="https://blog.csdn.net/collegeyuan/article/details/84764785" target="_blank">              		<h4 class="text-truncate oneline" style="width: 633px;"><em>Struts</em><em>异常</em><em>处理</em><em>机制</em> - collegeyuan的专栏 - CSDN博客</h4>                  <div class="info-box d-flex align-content-center">                    <p>                      <span class="date">10-9</span>                    </p>                  </div>                </a>            	</div>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
Struts2声明式异常处理 - 红桃峰峰 的博客 - CSDN博客

10-5

struts2中的异常映射处理机制 - VipMao的博客 - CSDN博客

10-6

<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_61" data-pid="61"><iframe src="https://adaccount.csdn.net/#/preview/263?m=cEEbQQHntEALLbpicADiJLASJnybAiJHnJcEtJSQnSmLvtpttHXpStcJtEHDpXUtHQnWcSELvJfQyyppotbiAmtJAiSHtDQELEAQ&amp;k=" frameborder="0" width="100%" height="75px" scrolling="no"></iframe><img class="pre-img-lasy" data-src="https://kunyu.csdn.net/1.png?d=2&amp;k=&amp;m=cEEbQQHntEALLbpicADiJLASJnybAiJHnJcEtJSQnSmLvtpttHXpStcJtEHDpXUtHQnWcSELvJfQyyppotbiAmtJAiSHtDQELEAQ"></div></div><div class="recommend-item-box baiduSearch recommend-box-ident" data-report-view="{&quot;mod&quot;:&quot;popu_387&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/tianyulinger3344/article/details/7554226/&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:&quot;9&quot;}" data-report-click="{&quot;mod&quot;:&quot;popu_387&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/tianyulinger3344/article/details/7554226/&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:&quot;9&quot;}" data-track-view="{&quot;mod&quot;:&quot;popu_387&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/tianyulinger3344/article/details/7554226/&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:8,&quot;extend1&quot;:&quot;_&quot;}" data-track-click="{&quot;mod&quot;:&quot;popu_387&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/tianyulinger3344/article/details/7554226/&quot;,&quot;strategy&quot;:&quot;searchFromBaidu1&quot;,&quot;index&quot;:8,&quot;extend1&quot;:&quot;_&quot;}" data-flg="true">                <a href="https://blog.csdn.net/tianyulinger3344/article/details/7554226/" target="_blank">              		<h4 class="text-truncate oneline" style="width: 626px;"><em>Struts</em><em>2</em> <em>异常</em><em>处理</em><em>机制</em> - tianyulinger3344的专栏 - CSDN博客</h4>                  <div class="info-box d-flex align-content-center">                    <p>                      <span class="date">10-20</span>                    </p>                  </div>                </a>            	</div>
  • 1
<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_62" data-pid="62"><iframe src="https://adaccount.csdn.net/#/preview/677?m=cbEtfvHDQtvnJnHpciUbQypHXEDHXSyyHiSAAnLEAbAbQpbpJiLtWcpALpJpbEQQAJXSbEfJtivXcAbpAbAHJScSLLQLStAbbSLQ&amp;k=" frameborder="0" width="100%" height="75px" scrolling="no"></iframe><img class="pre-img-lasy" data-src="https://kunyu.csdn.net/1.png?d=2&amp;k=&amp;m=cbEtfvHDQtvnJnHpciUbQypHXEDHXSyyHiSAAnLEAbAbQpbpJiLtWcpALpJpbEQQAJXSbEfJtivXcAbpAbAHJScSLLQLStAbbSLQ"></div></div>
  • 1
<div class="recommend-item-box recommend-box-ident recommend-download-box clearfix" data-report-view="{&quot;mod&quot;:&quot;popu_387&quot;,&quot;dest&quot;:&quot;https://download.csdn.net/download/yecaiyu/8690239&quot;,&quot;strategy&quot;:&quot;BlogCommendFromMachineLearnPai2&quot;,&quot;index&quot;:&quot;21&quot;}" data-report-click="{&quot;mod&quot;:&quot;popu_387&quot;,&quot;dest&quot;:&quot;https://download.csdn.net/download/yecaiyu/8690239&quot;,&quot;strategy&quot;:&quot;BlogCommendFromMachineLearnPai2&quot;,&quot;index&quot;:&quot;21&quot;}">
	<a href="https://download.csdn.net/download/yecaiyu/8690239" rel="noopener" target="_blank">
		<div class="content clearfix">
			<div class="">
				<h4 class="text-truncate oneline clearfix">
					<em>Struts</em><em>2</em> <em>异常</em><em>处理</em>的四种获取属性方法					</h4>
				<span class="data float-right">05-12</span>
			</div>
			<div class="desc oneline">
					Struts2 异常处理的四种获取属性方法,大家可以借鉴学习				</div>
			<span class="type-show type-show-download">下载</span>
		</div>
	</a>
</div>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
Struts2 的action中抛出异常,没有跳转到异常处理页面
12-16

struts2配置文件:<interceptors> <interceptor name="customer_exception" class="com.xx.ExceptionInterceptor 论坛

<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_63" data-pid="63"><iframe src="https://adaccount.csdn.net/#/preview/575?m=bESAcAASJtQLivHipicpicypbEbbSiAHAtcDDcHnLLbEJXLUpHnJvyJnAbtvtEiLLEtiHLQWpQEEoLccnnymbLfimHpLiSESJcQQ&amp;k=" frameborder="0" width="100%" height="75px" scrolling="no"></iframe><img class="pre-img-lasy" data-src="https://kunyu.csdn.net/1.png?d=2&amp;k=&amp;m=bESAcAASJtQLivHipicpicypbEbbSiAHAtcDDcHnLLbEJXLUpHnJvyJnAbtvtEiLLEtiHLQWpQEEoLccnnymbLfimHpLiSESJcQQ"></div></div>
  • 1
struts2配置之全局result及异常处理

09-27 阅读数 3151

struts2配置之全局result及异常处理 博文 来自: 菜鸟也疯狂

struts2与ajax的全局异常错误处理问题
07-04

现实需要要用$.ajax向后台传送复杂形式的数据,所以$.post不能满足需求 例如: $.ajax({ url:"customerAction_getById.action", data:"{'ci 论坛

<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_64" data-pid="64"><script type="text/javascript">
(function() {
    var s = "_" + Math.random().toString(36).slice(2);
    document.write('<div style="" id="' + s + '"></div>');
    (window.slotbydup = window.slotbydup || []).push({
        id: "u3600856",
        container:  s
    });
})();
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

请问下,struts2为什么我配置了注解后,全局异常就不起作用了啊
10-16

在配置文件里写就会去作用。 论坛

<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_65" data-pid="65"><script type="text/javascript">
    (function() {
        var s = "_" + Math.random().toString(36).slice(2);
        document.write('<div style="" id="' + s + '"></div>');
        (window.slotbydup = window.slotbydup || []).push({
            id: "u4221803",
            container: s
        });
    })();
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

<div class="recommend-item-box recommend-recommend-box"><div id="kp_box_66" data-pid="66"><div id="three_ad38" class="mediav_ad"></div>
  • 1
我花了一夜用数据结构给女朋友写个H5走迷宫游戏

09-21 阅读数 13万+

起因

又到深夜了,我按照以往在csdn和公众号写着数据结构!这占用了我大量的时间!我的超越妹妹严重缺乏陪伴而 怨气满满!

而女朋友时常埋怨,认为数据结构这么抽象难懂的东西没啥作用,常会问道…


博文



不识 Pandas,纵是老手也枉然?

09-13 阅读数 2425

作者 |周志鹏

责编 | 郭 芮

这段时间和一些做数据分析的同学闲聊,我发现数据分析技能入门阶段存在一个普遍性的问题,很多凭着兴趣入坑的同学,都能够很快熟悉Python基础语法,然后不约而同的一头…


博文



作者|王琳

本文经授权转载自燃财经(ID:rancaijing)

9月10日,张勇转正了,他由阿里巴巴董事局…


博文



<div class="recommend-item-box recommend-recommend-box"><div id="_ps9zmr387vs" style=""><iframe width="900" frameborder="0" height="90" scrolling="no" src="https://pos.baidu.com/s?hei=90&amp;wid=900&amp;di=u3491668&amp;ltu=https%3A%2F%2Fblog.csdn.net%2Ftianyulinger3344%2Farticle%2Fdetails%2F7554226&amp;psi=07aafcf1b822ca1e35d681cb72d4ec28&amp;tcn=1573470241&amp;tpr=1573470241377&amp;ant=0&amp;cec=UTF-8&amp;col=zh-CN&amp;ps=13915x397&amp;ari=2&amp;cce=true&amp;ltr=https%3A%2F%2Fblog.csdn.net%2FPastthewind%2Farticle%2Fdetails%2F81839651&amp;ti=Struts2%20%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86%E6%9C%BA%E5%88%B6&amp;psr=1920x1080&amp;dc=3&amp;chi=1&amp;par=1920x1040&amp;cdo=-1&amp;dri=1&amp;drs=1&amp;dai=4&amp;pss=1242x16587&amp;dtm=HTML_POST&amp;cmi=35&amp;ccd=24&amp;cja=false&amp;pcs=1242x615&amp;prot=2&amp;pis=-1x-1&amp;cpl=19&amp;tlm=1573470241&amp;exps=111000&amp;cfv=0&amp;dis=0"></iframe></div><script type="text/javascript" src="//rabc1.iteye.com/production/res/rxjg.js?pkcgstj=jm"></script></div>
  • 1
程序员终极面试指南!

09-14 阅读数 1823

身为技术人,如何拿下自己心仪的 offer?

作者|James Bedford

译者 |苏本如,责编 | 屠敏

出品 | CSDN(ID:CSDNnews)

以下为译文:

介绍




博文



我在快手认识了 4 位工程师,看到了快速发展的公司和员工如何彼此成就!

09-16 阅读数 2万+

作者 | 胡巍巍

出品 | CSDN(ID:CSDNnews)

从西二旗地铁站B口出来,步行700多米可以看到一个工业建筑风格的院子。这个独立的院子和后厂村各大互联网公司的高楼林立有些不同。

院…


博文



让程序员崩溃的瞬间(非程序员勿入)

09-16 阅读数 19万+

今天给大家带来点快乐,程序员才能看懂。

来源:https://zhuanlan.zhihu.com/p/47066521

  1. 公司实习生找 Bug

2.在调试时,将断点设…


博文



用Python分析2000款避孕套,得出这些有趣的结论

09-18 阅读数 3万+

到现在为止,我们的淘宝教程已经写到了第四篇,前三篇分别是:

第一篇:Python模拟登录淘宝,详细讲解如何使用requests库登录淘宝pc端。
第二篇:淘宝自动登录2.0,新增Cookies序列化…


博文



<div class="recommend-item-box recommend-recommend-box"><div id="_pilo2xft83f" style=""><iframe width="900" frameborder="0" height="90" scrolling="no" src="//pos.baidu.com/s?hei=90&amp;wid=900&amp;di=u3491668&amp;ltu=https%3A%2F%2Fblog.csdn.net%2Ftianyulinger3344%2Farticle%2Fdetails%2F7554226&amp;psi=07aafcf1b822ca1e35d681cb72d4ec28&amp;col=zh-CN&amp;ari=2&amp;cec=UTF-8&amp;pcs=1242x615&amp;cdo=-1&amp;ps=14420x397&amp;par=1920x1040&amp;ti=Struts2%20%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86%E6%9C%BA%E5%88%B6&amp;psr=1920x1080&amp;tcn=1573470241&amp;tlm=1573470241&amp;pis=-1x-1&amp;dis=0&amp;tpr=1573470241377&amp;drs=1&amp;prot=2&amp;cpl=19&amp;cja=false&amp;chi=1&amp;cmi=35&amp;dtm=HTML_POST&amp;ant=0&amp;dc=3&amp;ccd=24&amp;cce=true&amp;exps=111000&amp;cfv=0&amp;pss=1242x16682&amp;dri=2&amp;dai=5&amp;ltr=https%3A%2F%2Fblog.csdn.net%2FPastthewind%2Farticle%2Fdetails%2F81839651"></iframe></div><script type="text/javascript" src="//rabc1.iteye.com/production/res/rxjg.js?pkcgstj=jm"></script></div>
  • 1

这篇文章很长,但绝对是精华,相信我,读完以后,你会知道学历不好的解决方案…


博文



帮助蹲厕族、YP族、饭圈女孩在无聊之余可以有一样东西让他们振作起来!让他们的左手 / …


博文



redis——相关问题汇总

10-16 阅读数 1万+

什么是redis?

Redis 本质上是一个 Key-Value 类型的内存数据库, 整个数据库加载在内存当中进行操作, 定期通过异步操作把数据库数据 flush 到硬盘上进行保存。

因为是纯内…


博文



【JS 口袋书】第 6 章:JS 对象生命周期的秘密

10-16 阅读数 398

作者:valentinogagliardi来源:github译者:前端小智

阿里云最近在做活动,低至2折,有兴趣可以看看:

https://promotion.aliyun.com/ntms/…


博文



SQL基本语法入门 看这里就够了

10-21 阅读数 1237

SQL执行顺序

第一步:执行FROM

第二步:WHERE条件过滤

第三步:GROUP BY 分组

第四步:执行SELECT 投影列

第五步:HAVING条件过滤

第六步:执行ORDER B…


博文



动…


博文



用到的库:



博文



从月薪3K的中专生,到身家千万的CTO!人生最大的对手,就是自已

10-25 阅读数 1万+

关注“技术领导力”博客,独家大厂干货推送

文/Daniel.W

David坐在我对面,窗外是梦境般的外滩夜景,繁星点点的璀璨灯火,散落在黄浦江两岸。我转过头对David说,你丫挺会享受啊,约我…


博文



这应该是把计算机网络五层模型讲的最好是文章了,看不懂你打我

10-25 阅读数 2万+

帅地:用心写好每一篇文章!

前言
天各一方的两台计算机是如何通信的呢?在成千上万的计算机中,为什么一台计算机能够准确着寻找到另外一台计算机,并且把数据发送给它呢?
可能很多人都听说过网络通信的 5 …


博文



                <div class="recommend-item-box type_hot_word">
                                    <div class="content clearfix" style="width: 712px;">
                    <div class="float-left">
                                            <span>
                        <a href="https://www.csdn.net/gather_14/MtTaQg4sLWRvd25sb2Fk.html" target="_blank">
                        c#后台强行跳转</a>
                    </span>
                                            <span>
                        <a href="https://www.csdn.net/gather_1f/MtTaQg5sLWRvd25sb2Fk.html" target="_blank">
                        c#数据拼接</a>
                    </span>
                                            <span>
                        <a href="https://www.csdn.net/gather_17/MtTaUgwsLWRvd25sb2Fk.html" target="_blank">
                        c# cookie 遍历</a>
                    </span>
                                            <span>
                        <a href="https://www.csdn.net/gather_1a/MtTaUgxsLWRvd25sb2Fk.html" target="_blank">
                        c# 去除空格</a>
                    </span>
                                            <span>
                        <a href="https://www.csdn.net/gather_13/MtTaUgysLWRvd25sb2Fk.html" target="_blank">
                        c#读取tiff未bmp</a>
                    </span>
                                            <span>
                        <a href="https://www.csdn.net/gather_1b/MtTaUgzsLWRvd25sb2Fk.html" target="_blank">
                        c# 识别回车</a>
                    </span>
                                            <span>
                        <a href="https://www.csdn.net/gather_11/MtTaUg0sLWRvd25sb2Fk.html" target="_blank">
                        c#生成条形码ean13</a>
                    </span>
                                            <span>
                        <a href="https://www.csdn.net/gather_12/MtTaUg1sLWRvd25sb2Fk.html" target="_blank">
                        c#子控制器调用父控制器</a>
                    </span>
                                            <span>
                        <a href="https://www.csdn.net/gather_11/MtTaUg2sLWRvd25sb2Fk.html" target="_blank">
                        c# 写大文件</a>
                    </span>
                                            <span>
                        <a href="https://www.csdn.net/gather_16/MtTaUg3sLWRvd25sb2Fk.html" target="_blank">
                        c# 浏览pdf</a>
                    </span>
                                            </div>
                </div>
                                    </div>
                                <div class="recommend-loading-box">
                <img src="https://csdnimg.cn/release/phoenix/images/feedLoading.gif">
            </div>
            <div class="recommend-end-box">
                <p class="text-center">没有更多推荐了,<a href="https://blog.csdn.net/" class="c-blue c-blue-hover c-blue-focus">返回首页</a></p>
            </div>
        </div>
                        <div class="template-box">
                <span>©️2019 CSDN</span><span class="point"></span>
            <span>皮肤主题: 大白</span>
            <span> 设计师:
                                        CSDN官方博客                                    </span>
            </div>
                </main>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号