- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有谁知道如何在 spring 中使用自定义 ThemeSource?我已经看到许多关于如何使用 ResourceBundleThemeSource 将主题与属性文件一起使用的示例。然而,我没有看到如何使用 hibernate 来存储各种属性(例如单个 css 属性),使用自定义 ThemeSource 读取属性,并且仍然能够在 jsp 中使用 spring 主题标签。
我知道我可以创建一个 Controller 并使用 hibernate 从数据库中获取这些属性,但我更想知道如何使用 Spring 的 ThemeSource 实现来做到这一点。
如果有人有任何想法或示例,我将不胜感激。
谢谢
最佳答案
要在您的 Web 应用程序中使用主题,您必须设置 org.springframework.ui.context.ThemeSource
的实现。界面。要使用自定义 ThemeSource 实现,您可以在应用程序上下文中使用保留名称 themeSource
注册一个 bean。 . Web 应用程序上下文会自动检测具有该名称的 bean 并使用它。
这是ThemeSource
界面:
package org.springframework.ui.context;
public interface ThemeSource {
Theme getTheme(String themeName);
}
Theme
类型,实际上无非是:
package org.springframework.ui.context;
public interface Theme {
String getName();
MessageSource getMessageSource();
}
Theme
已经有了一个方便的实现。来自 Spring 的类型 =>
SimpleTheme
MessageSource
一起使用。界面。
DatabaseDrivenMessageSource
,或者直接从
here 获取
DatabaseThemeSource
(这将成为
themeSource
bean):
public class DatabaseThemeSource implements ThemeSource {
private YourThemeDao themeDao;
public Theme getTheme( String themeName ) {
if (themeName == null) { return null; }
MessageSource messageSource = new DatabaseDrivenMessageSource( themeDao );
theme = new SimpleTheme( themeName, messageSource );
return theme;
}
// init your themeDao
}
关于java - 通过实现 Spring 的 ThemeSource 类实现带有 hibernate 的 Spring 主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7560002/
目前我正在尝试在我的 Electron 应用程序中设置系统/亮/暗模式切换器。对于 Electron 应用程序,我使用了 electron-vue 库,然后将 Electron 版本升级到 7.3.2
我无法设置我的 Electron 应用程序的themeSource。平台是Windows 8.1。 const electron = require('electron'); const app =
有谁知道如何在 spring 中使用自定义 ThemeSource?我已经看到许多关于如何使用 ResourceBundleThemeSource 将主题与属性文件一起使用的示例。然而,我没有看到如何
我是一名优秀的程序员,十分优秀!