struts.xml
<!-- 定义全局结果 -->
<global-results>
<result name="login">/login.jsp</result>
<result name="search">/WEB-INF/pages/search.jsp</result>
<result name="error">/error.jsp</result>
</global-results>
<!-- 定义全局异常映射 -->
<global-exception-mappings>
<!-- Action抛出的AppException异常时,转入名为exception的结果 -->
<exception-mapping exception="com.struts.common.AppException" result="error">
</exception-mapping>
</global-exception-mappings>Action
try{
pm.setProj_id(proj_id);
pmd.loadOther(pm);
pmd.add(pm);
//创建关于增加成员的操作记录
String descrip="增加了一个项目成员:"+pm.getChina_domain_id();
UpdateRecordAction ur=new UpdateRecordAction (descrip);
ur.loadUpadateRecord();
}catch(Exception e){
throw new AppException("增加成员时发生错误,请重新尝试!");
}页面上
<td>
<!-- 通过struts2标签输出异常对象的message属性 -->
<s:property value="exception.message"/>
</td>问题是抛异常时虽然转到这个页面但是却不打印异常的Message信息“增加成员时发生错误,请重新尝试”
<!-- 定义全局结果 -->
<global-results>
<result name="login">/login.jsp</result>
<result name="search">/WEB-INF/pages/search.jsp</result>
<result name="error">/error.jsp</result>
</global-results>
<!-- 定义全局异常映射 -->
<global-exception-mappings>
<!-- Action抛出的AppException异常时,转入名为exception的结果 -->
<exception-mapping exception="com.struts.common.AppException" result="error">
</exception-mapping>
</global-exception-mappings>Action
try{
pm.setProj_id(proj_id);
pmd.loadOther(pm);
pmd.add(pm);
//创建关于增加成员的操作记录
String descrip="增加了一个项目成员:"+pm.getChina_domain_id();
UpdateRecordAction ur=new UpdateRecordAction (descrip);
ur.loadUpadateRecord();
}catch(Exception e){
throw new AppException("增加成员时发生错误,请重新尝试!");
}页面上
<td>
<!-- 通过struts2标签输出异常对象的message属性 -->
<s:property value="exception.message"/>
</td>问题是抛异常时虽然转到这个页面但是却不打印异常的Message信息“增加成员时发生错误,请重新尝试”
页面用<s:fielderror/>