English 中文(简体)
特殊电文
原标题:Exception Messages
  • 时间:2012-04-19 09:34:22
  •  标签:
  • struts2

I want to display Custom pages with custom message when exception is raised. For this i am doing like this.

行动类别:

catch(OrbytTvException e) {
    result=NONE;
    Error err=new Error();
    err.setErrMsg("Exception Occured");
    log.info(err.getErrMsg());
    request.setAttribute("error", err);
} 

Struts.xml:

<result name="none">/WEB-INF/pages/error.jsp</result>

Error ---- This is a bean contains errMsg property.

此处提及的例外情况 我为这一财产设定了一种价值。

页: 1

<s:bean name="com.sits.itv.util.Error" var="errorBean" />
  <s:property value="#errorBean.errMsg"/>

在这里,我展示了手法,但显示它是无效的。

请帮助我如何在休战中展示习俗信息。

问题回答

我认为,在《国际会计准则》中显示这一例外情况,第2条提供了一种清洁的方法,可以做到这一点,即:违约,ExceptionMappingInterceptor。 在价值中增加以下数值:

  1. exception The exception object itself
  2. exceptionStack The value from the stack trace

你们都需要这样做。

<s:property value="%{exception.message}"/>
  <s:property value="%{exceptionStack}"/> 

详情见官方文件c

此外,您不需要做以下工作:request.setAttribute (“error”) err;,因为S2提供了干净的,因此,你们都需要在自己的行动类别中与其采集器和制片人申报财产,而且你可以自由地将财产作为价值衡量的一部分提供。

But still i believe that should not be the way to show information to the user and its always better to use framework provides way which is more flexible and easy to use





相关问题
Getting sitemesh to work with struts2

I m trying to integrate sitemesh into my struts2 app, but i m finding that it s not making any difference and isn t showing any errors (or anything sitemesh related at all) in the logs. I ve started ...

Struts Action Validation

Hey People. I have been recently validating Struts 2 actions. In One of my action class, the save method to be precise must have two id s. That is an assessmenttype id and a course id. this is what is ...

struts2 action not calling properly

On default I want my struts2 app to forward to an action: <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"...

How to validate a select tag in struts 2 framework

I am a newbie into programming and i am currently employed as a junior programmer. I am currently having some problems validating the select tags in one of my forms. What i actually trying to do is to ...

Setting the default value in Struts2

I am setting the value(kind of default value) for a drop down select value from action class in a page(given below). When the page loads the value is beig displayed but the other elements of the ...

Localized exceptions (within a Struts2 app)

I am developing a Struts 2 application with support for multiple languages. If one of the domain objects needs to throw an exception, how can it do so in such a way that the error message is no ...

热门标签