一,springboot中

看一下代码:

@Controller
public class HelloController {
//读取枚举值
@Value("#{T(com.example.demo.model.EnumList.EnumList.TrackTraceState).Booking.getEnumItem().getItemCN()}")
private String pwd; //读取方法
@Value("#{T(com.example.demo.controller.HelloController).GetName()}")
private String name; public static String GetName()
{
return "hello";
} //读取配置文件
@Value("${girl.age}")
private Integer age; @RequestMapping("/index.do")
public String say(ModelMap mode) { User u=new User();
u.setUserName(name);
u.setAge(age);
u.setPassword(pwd);
mode.addAttribute("user", u);
return "say";
} }

application.yml:

girl:
name: uiw
age: 33

html:

<div th:text="${user.userName}"></div>
<div th:text="${user.password}"></div>
<div th:text="${user.age}"></div>
<div th:text="${T(com.example.demo.model.EnumList.EnumList.IsApprovalEnum).Approved.getEnumItem().getItemCN()}" />

pwd: 调用的枚举值,以及方法返回枚举值的中文名

name:调用的静态方法GetName

age:读取配置文件

最后一个:是thymeleaf 调用后台枚举值的方法。

呈现:

PS:

${} 读取上下文的属性值

#{} 启用Spring表达式,具有运算能力

二,SpringMvc / Module模块引用(例子是SqlHelper)

首先springmvc-servlet.xml中 引入属性文件

<!-- 引入属性文件 -->
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:properties/env.properties</value>
<value>classpath:properties/jdbc.properties</value>
</list>
</property>
</bean>

继续添加模块的bean

<bean id="sqlHelper" class="com.kintech.SQLServer.SqlHelper" />

调用时使用 @Autowired

@Autowired
SqlHelper sh; @RequestMapping(value = "test01.do")
public String test01(ModelMap mode) {
sh.getConn();
return "test/test01";
}

看一下SqlHelper

springboot EL @Value的更多相关文章

  1. springboot启动tomcat报错java.lang.NoClassDefFoundError: javax/el/ELManager仅记录

    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'o ...

  2. 外部tomcat发布springboot项目步骤和异常处理:java.lang.NoClassDefFoundError: javax/el/ELManager

  3. Thymeleaf模板引擎与springboot关联后,在html中无法使用el表达式获取model存的值

    头部引入了thymeleaf <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thy ...

  4. Springboot基础篇

    Springboot可以说是当前最火的java框架了,非常适合于"微服务"思路的开发,大幅缩短软件开发周期. 概念 过去Spring充满了配置bean的xml文件,随着spring ...

  5. springboot(四):thymeleaf使用详解

    在上篇文章springboot(二):web综合开发中简单介绍了一下thymeleaf,这篇文章将更加全面详细的介绍thymeleaf的使用.thymeleaf 是新一代的模板引擎,在spring4. ...

  6. (二)springboot整合thymeleaf模板

    在我们平时的开发中,用了很久的jsp作view显示层,但是标签库和JSP缺乏良好格式的一个副作用就是它很少能够与其产生的HTML类似.所以,在Web浏览器或HTML编辑器中查看未经渲染的JSP模板是非 ...

  7. 整合springboot(app后台框架搭建四)

    springboot可以说是为了适用SOA服务出现,一方面,极大的简便了配置,加速了开发速度:第二方面,也是一个嵌入式的web服务,通过jar包运行就是一个web服务: 还有提供了很多metric,i ...

  8. SPRINGBOOT 读书笔记

    Spring基础 Spring的发展 xml配置 注解配置 Java配置 Spring模块:核心容器 AOP 消息 web 数据访问集成 常用的:@Component @Service @Reposi ...

  9. 解决spring-boot启动中碰到的问题:Cannot determine embedded database driver class for database type NONE

    问题 如下: 2017-07-16 08:50:57.436  INFO 13524 --- [           main] c.p.p.web.PointshopWebApplication   ...

随机推荐

  1. ICPC Asia Nanning 2017 L. Twice Equation (规律 高精度运算)

    题目链接:Twice Equation 比赛链接:ICPC Asia Nanning 2017 Description For given \(L\), find the smallest \(n\) ...

  2. https://blog.csdn.net/rubbertree/article/details/88877262

    本文链接:https://blog.csdn.net/rubbertree/article/details/88877262 https://blog.csdn.net/mingtianhaiyouw ...

  3. Java.util.ArrayDeque类

    java.util.ArrayDeque 类提供了可调整大小的阵列,并实现了Deque接口.以下是关于阵列双端队列的要点: 数组双端队列没有容量限制,使他们增长为必要支持使用. 它们不是线程安全的;如 ...

  4. Vuex 源码解析

    先来看一下这张Vuex的数据流程图,熟悉Vuex使用的同学应该已经有所了解. Vuex实现了一个单向数据流,在全局拥有一个State存放数据,所有修改State的操作必须通过Mutation进行,Mu ...

  5. PWM,SBUS,PPM信号转模拟电压的方案

    PWM,SBUS,PPM信号转模拟电压的方案 -----------------本文由"麦粒电子"撰写,并提供相应产品服务.---------------- 案例场景 有个内部采用 ...

  6. top.location.href

    window.location.href.location.href是本页面跳转   parent.location.href是上一层页面跳转   top.location.href是最外层的页面跳转 ...

  7. 二分法的应用:POJ1064 Cable master

    /* POJ1064 Cable master 时间限制: 1000MS 内存限制: 10000K 提交总数: 58217 接受: 12146 描述 Wonderland的居民已经决定举办地区性编程比 ...

  8. 57 c++ 读取二进制文件: 以.raw后缀的TDF_Voxel_Size文件为例

    0 引言 毕业设计中用到了.raw格式的文件,需要将该文件按照M*N*P的矩阵格式加载到内存中.采用 #include <fstream> 中的FILE* 加载,并针对数据占用字节数,以 ...

  9. java基础编程题(2)

    1.给定一个二叉树,找出其最大深度. 注:二叉树的深度为根节点到最远叶子节点的最长路径上的节点数. /** * Definition for a binary tree node. * public ...

  10. Centos搭建http代理服务器(无密码验证)

    一.安装shadowsocks yum install python-setuptools && easy_install pip pip install shadowsocks 二. ...