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. 剑指offer_面试题_从上往下打印二叉树

    题目:从上往下打印出二叉树的每一个结点.同一层的结点依照从左到右的顺序打印.比如输入图4.5中的二叉树.则依次打印出8.6.10.5.7.9.11. 8 /     \ 6     10 /   \ ...

  2. Swift 3.0(一)

    一:let 和 var let 声明的是一个常量, var 声明的是一个变量 二:简单数据类型 1.自推出数据类型 let implicitDouble = 70.0    //根据初始化时赋值的数据 ...

  3. zzulioj--1716--毒(模拟水题)

     1716: 毒 Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 96  Solved: 43 SubmitStatusWeb Board Desc ...

  4. luogu 1351 联合权值

    联合权值 题目大意 给你一个图,有\(n-1\)条边,距离均为\(1\),每距离为\(2\)的两个点的联合权值为\(W_u \times W_v\),求联合权值的最大值和联合权值总和. solutio ...

  5. SQL中一次插入多条数据

    SQL中insert一次可以插入一条数据,我们有三种方法可以一次性插入多条数据. 1. 语法:select 字段列表 into 新表 from 源表 注意事项:此种方法新表是系统自动创建,语句执行前不 ...

  6. 路飞学城Python-Day10

    [37.函数-命名空间]命名空间又称为name space,顾名思义就是存放名字的地方,存什么名字呢?举例说明,若变量 x = 1,存放于内存中,那名字x存放在哪里呢?名称空间正式存放名字x和1绑定关 ...

  7. NodeJS学习笔记 (1)资源压缩-zlib(ok)

    原文: https://github.com/chyingp/nodejs-learning-guide/blob/master/README.md 自己的跟进学习: 概览 做过web性能优化的同学, ...

  8. HDU 2782 The Worm Turns (DFS)

    Winston the Worm just woke up in a fresh rectangular patch of earth. The rectangular patch is divide ...

  9. 阿里云CentOS系统配置iptables防火墙

    虽说阿里云推出了云盾服务,但是自己再加一层防火墙总归是更安全些,下面是我在阿里云vps上配置防火墙的过程,目前只配置INPUT.OUTPUT和FORWORD都是ACCEPT的规则 一.检查iptabl ...

  10. Java NIO笔记(一):NIO介绍

    Java NIO即Java Non-blocking IO(Java非堵塞I/O),由于是在Jdk1.4之后添加的一套新的操作I/O工具包,所以通常会被叫做Java New IO.NIO是为提供I/O ...