博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring Theme简单应用
阅读量:7093 次
发布时间:2019-06-28

本文共 2008 字,大约阅读时间需要 6 分钟。

Spring MVC特性里由一个是关于Spring Theme主题的应用,所以写了个Demo

 

1.这里先看项目结构(Meven项目)

  

2.所需的POM依赖

org.springframework
spring-core
4.0.5.RELEASE
org.springframework
spring-beans
4.0.5.RELEASE
org.springframework
spring-context
4.0.5.RELEASE
org.springframework
spring-web
4.0.5.RELEASE
org.springframework
spring-webmvc
4.0.5.RELEASE

3.Properties Theme文件配置

4.编写HTML文件

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>    
Title
" type="text/css" />

你好,Hello Word

5.SpringMVC XML配置

 

6.编写Controller

package controller;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.servlet.ModelAndView;@Controllerpublic class FormController {    @RequestMapping(value = "/form")    public ModelAndView user() {        return new ModelAndView("form", "user","你好");    }}

 

备注:这样进行切换的时候,实际切换的是使用的文件,而JSP页面使用的Spring:Theme的Code属性实际是Theme Properties文件里面的Key值。

 

附录:

  Spring Framework官方文档:https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html#mvc-themeresolver

        W3C Spring MVC 4.2.4中文文档:https://www.w3cschool.cn/spring_mvc_documentation_linesh_translation/spring_mvc_documentation_linesh_translation-i79x27rz.html

转载于:https://www.cnblogs.com/XingXiaoMeng/p/10201712.html

你可能感兴趣的文章
设计模式 — 结构型模式 适配器模式
查看>>
Tempter of the Bone------剪枝
查看>>
Java学习笔记---IO操作
查看>>
Hadoop2
查看>>
"Chinese Pinyin"App-隐私政策
查看>>
java多态性,父类引用指向子类对象
查看>>
机器学习入门03 - 降低损失 (Reducing Loss)
查看>>
Material Design(七)--Snackbar
查看>>
文件MD5
查看>>
收集的博客网址springboot、cloud
查看>>
解析函數論 Page 29 命題(3) 模的下界的可達性
查看>>
windows异常调用顺序
查看>>
红黑树
查看>>
Sass
查看>>
Objective-C中Block语法、Block使用以及通过Block实现数组排序
查看>>
[转载]从业务运维转到产品经理,我摸爬滚打的产品之路
查看>>
比较正在使用的域名 和顶层窗口的域名
查看>>
Gitlab - Mac本机访问VirtualBox上搭建的Gitlab
查看>>
Bootstrap的Model源码详细注释 (转)
查看>>
java采用jxl写入一个Excel文件
查看>>