Spring SpEL in JSP and Assign SpEL value to Java variable in JSP

    method 1  use----ServletContextAttributeExporter
org.springframework.web.context.support.ServletContextAttributeExporter xml----->
-------------------
<bean class="org.springframework.web.context.support.ServletContextAttributeExporter">
<property name="attributes">
<map>
<entry key="attrname"><value>oracle_name</value></entry>
<entry key="attrvalue"><value>235</value></entry>
</map>
</property>
</bean> jsp----->
name: ${attrname}
password: ${attrvalue} <% //in jsp assign Spel(spring expression) value to java var
String attrname=(String)application.getAttribute("attrname");
String attrvalue=(String)application.getAttribute("attrvalue");
System.out.println(attrname+"----1-----"+attrvalue);
%>
-------------------- =================================================================================== method 2 use-----util:properties
add your.properties , add add next sentences xmlns:util="http://www.springframework.org/schema/util"
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd <util:properties id="comProp" location="classpath:/comProp.properties"/> jsp add
//show ,if not define var ,expression will show value direct. <%@taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %> <spring:eval expression="@comProp.getProperty('db_name')" var="db_name" scope="application"/>
<spring:eval expression="@comProp.getProperty('db_password')" var="db_password" scope="application"/> ${db_name} / ${db_password} <% //in jsp assign Spel(spring expression) value to java var
String abc=(String)application.getAttribute("db_name");
String abcd=(String)application.getAttribute("db_password");
System.out.println(abc+"---------"+abcd);
%> Reference SpEL tag https://docs.spring.io/spring/docs/current/spring-framework-reference/html/spring-tld.html#spring.tld.eval

Spring SpEL in JSP and Assign SpEL value to Java variable in JSP的更多相关文章

  1. Spring 使用介绍(四)—— SpEL

    一.SpEL介绍 Spring表达式语言全称为“Spring Expression Language”,缩写为“SpEL”,可在运行时构建复杂表达式 使用步骤: 1)创建解析器:ExpressionP ...

  2. Spring学习笔记(14)——SpEL

    是什么 Spring表达式语言全称为"Spring Expression Language",缩写为"SpEL",类似于Struts2x中使用的OGNL表达式语 ...

  3. springJDBC一对多关系,以及Java递归,jsp递归的实现

    maven编译,springMVC+spring+springJDBC框架. 要实现的功能是一个文件夹下,可能显示n个文件夹,每个文件夹下又可能显示n个文件夹.... 前台效果:

  4. struts采用JavaServlet/JSP技术,实现了基于Java EEWeb应用的MVC设计模式的应用框架

    今天我用Ecipse搭建Struts框架,并且使用Struts框架编写一个最简单的例子,相信读者能够很容易的明白. Struts是当今Java比较流行的三大框架之一,三大框架是Struts,sprin ...

  5. Cannot resolve taglib with uri http://java.sun.com/jsp/jstl/core

    问题 <Spring 实战>第5章,在 IDEA 中 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" pre ...

  6. JAVA SpringBoot2 整合 JSP视图模板 整合 Ueditor富文本编辑器

    一般涉及到后台管理系统,就少不了富文本编辑器,这个可以图,文,视频混排的高级工具,笔者通过对比,发现目前市场上最好的三方库还当属百度的 ueditor 近年来 SpringBoot 框架可谓越来越火, ...

  7. Spring 4.x Task 和 Schedule 概述(代java配置)

    转载请注明https://zhangzhaoyu.github.io/2016/09/30/spring-task-and-schedule-deep-research/ 摘要 在很多业务场景中,系统 ...

  8. Java Web之JSP技术

    JSP全称是Java Server Pages,它和servle技术一样,都是SUN公司定义的一种用于开发动态web资源的技术.JSP这门技术的最大的特点在于,写jsp就像在写html,但它相比htm ...

  9. Java开发之JSP行为

    一.Java Bean行文 1.重点说明 Java Bean行为是一组与Java Bean相关的行为,包括useBean行为.setProperty行为.getProperty行为等.Java Bea ...

随机推荐

  1. System.getProperty()方法可以获取的值

    /** 获得当前类的完整路径.最后一句 */ package org.outman.dms.server; import java.net.MalformedURLException; import ...

  2. centos6高速部署java应用

    眼下提供IDC服务的厂商真的是五花八门,可是更正服务到位的却为数不多,搞得比較好的应该是阿里云.天成.51idc,出于时间考虑还是建议选用windows,至少安装开发环境会方便得多,不会耗费太长时间. ...

  3. HTML5学习笔记(一):HTML5基本概念

    1.HTML的发展历程 HTML(1994年,W3C成立) HTML2(1995年) HTML3(1996年) HTML4.0(1997年) HTML4.01(1999年)——HTML5(2008年: ...

  4. 【原创】Apache集群报Service Temporarily Unavailable的解决

    Apache的集群突然时不时的报出以下错误: Service Temporarily Unavailable The server is temporarily unable to service y ...

  5. jquery根据接口返回的值来设置asp:CheckBoxList的选中值

    接口返回一个json的值,然后通过jquery来选中asp:CheckBoxList相应选中的值 <asp:CheckBoxList runat="server" Repea ...

  6. Codeforces Round #289 Div 2

    A. Maximum in Table 题意:给定一个表格,它的第一行全为1,第一列全为1,另外的数满足a[i][j]=a[i-1][j]+a[i][j-1],求这个表格中的最大的数 a[n][n]即 ...

  7. windows2008搭建ftp服务器

    控制面板 操作—〉添加角色 (web,文件服务) windows 搜索中: 添加ftp站点: 计算机---管理 –服务器管理  --- 添加一个用户 ,密码. 防护墙高级设置中添加 出入站规则 允许2 ...

  8. 不实例化一个 class 的时候使用它的property

    class A: @property def name(self): " print(A.name) # <property object at 0x10d54cf98> cla ...

  9. React 第三天

    第三天 01:在组件中使用style行内对象并封装样式对象: CmtItem.jsx: import React from 'react' //第一层封装 将样式对象和UI结构分离 // const ...

  10. luogu P3396 哈希冲突(分块?)

    我们可以维护一个\(f[i][j]\)代表%\(i\)意义下得\(j\)的答案.然后维护就炸了. 先设\(x=\sqrt{n}\)然后我们发现,当\(i>x\)时我们直接暴力复杂度为\(O(x) ...