Spring SpEL in JSP and Assign SpEL value to Java variable in JSP
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的更多相关文章
- Spring 使用介绍(四)—— SpEL
一.SpEL介绍 Spring表达式语言全称为“Spring Expression Language”,缩写为“SpEL”,可在运行时构建复杂表达式 使用步骤: 1)创建解析器:ExpressionP ...
- Spring学习笔记(14)——SpEL
是什么 Spring表达式语言全称为"Spring Expression Language",缩写为"SpEL",类似于Struts2x中使用的OGNL表达式语 ...
- springJDBC一对多关系,以及Java递归,jsp递归的实现
maven编译,springMVC+spring+springJDBC框架. 要实现的功能是一个文件夹下,可能显示n个文件夹,每个文件夹下又可能显示n个文件夹.... 前台效果:
- struts采用JavaServlet/JSP技术,实现了基于Java EEWeb应用的MVC设计模式的应用框架
今天我用Ecipse搭建Struts框架,并且使用Struts框架编写一个最简单的例子,相信读者能够很容易的明白. Struts是当今Java比较流行的三大框架之一,三大框架是Struts,sprin ...
- 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 ...
- JAVA SpringBoot2 整合 JSP视图模板 整合 Ueditor富文本编辑器
一般涉及到后台管理系统,就少不了富文本编辑器,这个可以图,文,视频混排的高级工具,笔者通过对比,发现目前市场上最好的三方库还当属百度的 ueditor 近年来 SpringBoot 框架可谓越来越火, ...
- Spring 4.x Task 和 Schedule 概述(代java配置)
转载请注明https://zhangzhaoyu.github.io/2016/09/30/spring-task-and-schedule-deep-research/ 摘要 在很多业务场景中,系统 ...
- Java Web之JSP技术
JSP全称是Java Server Pages,它和servle技术一样,都是SUN公司定义的一种用于开发动态web资源的技术.JSP这门技术的最大的特点在于,写jsp就像在写html,但它相比htm ...
- Java开发之JSP行为
一.Java Bean行文 1.重点说明 Java Bean行为是一组与Java Bean相关的行为,包括useBean行为.setProperty行为.getProperty行为等.Java Bea ...
随机推荐
- $(window).load(function(){})跟$(document).ready(function(){})跟$(function(){})区别
1.页面DOM加载完成 2.$(document).ready(function(){}) 的简写是 $(function(){}) 执行 3.图片样式等所有HTML元素加载完毕 4.$(windo ...
- 银行bank系统项目实践
想看项目的注意了!完整版银行管理系统就在这里看不看你看着办! 按照惯例咱们还是先来看一下项目需求: 某银行为了提高业务率希望开发一个银行管理系统功能如下: 1.能够完成用户开户操作 2.能够完成用户取 ...
- 根据ip地址获取城市
var ip=context.Request.UserHostAddress; string url = "http://int.dpool.sina.com.cn/iplookup/ipl ...
- ASP.NET使用MergeInto做数据同步,同步SQLSERVER不同数据库的相同表结构的数据
public string SynchronousData() { ReturnJson Rejson = new ReturnJson(); //将WebConfig中的数据库连接name中的值写进 ...
- shell-3.bash的基本功能:多命令顺序执行与管道符
1. 2.
- UVA-12186 Another Crisis 树形dp
题目链接:https://cn.vjudge.net/problem/UVA-12186 题意 给出n, T和一棵树,树上每个节点需要选择T%个直属子节点. 问根节点一共需要选择几个节点. 思路 思路 ...
- [codevs3269]混合背包
题目大意:一道混合背包模板. 解题思路:分三种情况讨论,01和完全没什么问题,多重背包需要把物品分成$\log W[i]$件,然后01即可,分成W[i]件01会TLE. 读优大法好! C++ Code ...
- CF1065D Three Pieces (多元最短路)
题目大意:给你一个棋盘,你需要控制棋子依次经过编号为1~n的所有点,棋子的可以是车,马,象,都依照国际象棋的行棋方式,每走一步消耗1单位时间,但每次更换棋子都需要额外1单位时间,求经过所有点需要的最少 ...
- AES对称加密util
package cn.com.qmhd.oto.common; import java.security.Key; import java.security.NoSuchAlgorithmExcept ...
- windows系统关闭端口占用进程
1.查找端口占用进程ID netstat -ano|findstr " 2.通过进程ID查找进程名 tasklist |findstr " 3.杀死进程(指定进程ID或进程名) t ...