stock images description properties file

This commit is contained in:
Jottyfan
2025-05-29 17:53:18 +02:00
parent 82ce501f39
commit 485a222be4
5 changed files with 60 additions and 10 deletions

View File

@@ -20,7 +20,7 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
public class Main extends SpringBootServletInitializer {
private static final Logger LOGGER = LogManager.getLogger(Main.class);
public static final Logger LOGGER = LogManager.getLogger(Main.class);
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {

View File

@@ -1,6 +1,8 @@
package de.jottyfan.camporganizer.module.staticpages;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -14,6 +16,9 @@ import de.jottyfan.camporganizer.module.camplist.CommonController;
@Controller
public class StaticPagesController extends CommonController {
@Autowired
private StaticPagesService service;
/**
* load the index page
*
@@ -21,7 +26,7 @@ public class StaticPagesController extends CommonController {
*/
@GetMapping("/")
public String getIndex() {
return "/allgemeines";
return "redirect:/allgemeines";
}
/**
@@ -70,7 +75,8 @@ public class StaticPagesController extends CommonController {
* @return the allgemeines page
*/
@GetMapping("/allgemeines")
public String getAllgemeines() {
public String getAllgemeines(final Model model) {
model.addAttribute("title", service.getStockDescription());
return "/allgemeines";
}

View File

@@ -0,0 +1,37 @@
package de.jottyfan.camporganizer.module.staticpages;
import java.io.IOException;
import java.util.Properties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Service;
import de.jottyfan.camporganizer.Main;
/**
*
* @author jotty
*
*/
@Service
public class StaticPagesService {
@Autowired
private ResourceLoader resourceLoader;
public Properties getStockDescription() {
Resource resource = resourceLoader.getResource(
"classpath:/static/images/stock.properties"
);
Properties properties = new Properties();
try {
properties.load(resource.getInputStream());
} catch (IOException e) {
Main.LOGGER.error(e.getMessage());
}
return properties;
}
}