您现在的位置是:首页 > 电脑技术查询 > web开发

jstl 页面展示control层中exception的message

编辑:chaxungu时间:2022-10-10 23:24:31分类:web开发

jstl 页面显示control层中exception的message

今天遇到了个问题,我在control中使用exception来处理跳转页面,

 

if(website.isClosed()) throw new WebsiteNotOpened(website.getCloseReason());

 问题就出来了,我还真不知道怎么使用jstl把这个message给取出来

 

注意!jslt中的却有<C:catch/>但是他是用来处理jsp也页面本身错误的,和control曾中的异常并没有关系。

 

然后,网上查了查,发现如下处理

 

先要在page声明中,加入isErrorPage="true"

<%@ page contentType="text/html;charset=UTF-8" isErrorPage="true" %>

 然后,使用这种表达方式

<%=exception.getMessage()%>

 暂时解决了这个问题,可能有更好的吧