5 changed files with 49 additions and 6 deletions
-
39src/main/java/com/heai/common/config/PdaTitleAdvice.java
-
6src/main/resources/application-dev.yml
-
2src/main/resources/mapper/pms/QcMapper.xml
-
4src/main/resources/templates/login.ftl
-
4src/main/resources/templates/pdaBase.ftl
@ -0,0 +1,39 @@ |
|||
package com.heai.common.config; |
|||
|
|||
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; |
|||
import org.springframework.core.io.ClassPathResource; |
|||
import org.springframework.web.bind.annotation.ControllerAdvice; |
|||
import org.springframework.web.bind.annotation.ModelAttribute; |
|||
|
|||
import java.util.Properties; |
|||
|
|||
/** |
|||
* 从 application-dev.yml 读取 PDA 标题并注入 Freemarker。 |
|||
* 不依赖当前 spring.profiles.active,避免 test/prod 环境读不到该文件。 |
|||
*/ |
|||
@ControllerAdvice |
|||
public class PdaTitleAdvice { |
|||
|
|||
private static final String DEFAULT_TITLE = "赫艾-PDA"; |
|||
|
|||
@ModelAttribute("project_title") |
|||
public String projectTitle() { |
|||
return loadPdaTitle(); |
|||
} |
|||
|
|||
private String loadPdaTitle() { |
|||
try { |
|||
YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean(); |
|||
yaml.setResources(new ClassPathResource("application-dev.yml")); |
|||
Properties properties = yaml.getObject(); |
|||
if (properties != null) { |
|||
String title = properties.getProperty("pda.title"); |
|||
if (title != null && !title.trim().isEmpty()) { |
|||
return title.trim(); |
|||
} |
|||
} |
|||
} catch (Exception ignored) { |
|||
} |
|||
return DEFAULT_TITLE; |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue