jsp 中获取自定义变量

首先确定El表达式的查找范围:

依次从Page、Request、Session、Application 中的 attribute属性中查找.

<%
                        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
                                + "/";
                        //设置为app路径
                        basePath += "venusApp/";%>

对于在jsp中自定义java变量El表达式如何获得?

request.setAttribute("basePath", basePath);

根据上述查找范围直接定义在attribute即可通过EL表达式  ${basePath}获得;

猜你喜欢

转载自www.cnblogs.com/lishuaiqi/p/10180509.html
今日推荐