|
|
@@ -1,10 +1,17 @@
|
|
|
package name.tflucke.ieat2.configs;
|
|
|
|
|
|
+import java.util.Map;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
+import javax.annotation.Resource;
|
|
|
|
|
|
+import org.apache.commons.logging.Log;
|
|
|
+import org.apache.commons.logging.LogFactory;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.beans.factory.config.PropertiesFactoryBean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
+import org.springframework.context.annotation.PropertySource;
|
|
|
+import org.springframework.core.io.ClassPathResource;
|
|
|
import org.springframework.web.servlet.ViewResolver;
|
|
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
|
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
@@ -20,7 +27,10 @@ import org.springframework.http.CacheControl;
|
|
|
* @since 2.0.0
|
|
|
*/
|
|
|
@Configuration
|
|
|
+@PropertySource("classpath:web.properties")
|
|
|
public class WebConfig implements WebMvcConfigurer {
|
|
|
+
|
|
|
+ private static final Log log = LogFactory.getLog(WebConfig.class);
|
|
|
|
|
|
/**
|
|
|
* Expiration time of web resources in seconds.
|
|
|
@@ -28,6 +38,12 @@ public class WebConfig implements WebMvcConfigurer {
|
|
|
@Value("${web.resources.timeout:0}")
|
|
|
private long timeout;
|
|
|
|
|
|
+ /**
|
|
|
+ * Properties available to JSP files.
|
|
|
+ */
|
|
|
+ @Resource(name="jspProperties")
|
|
|
+ private Map<String, Object> jspProperties;
|
|
|
+
|
|
|
/**
|
|
|
* Allows access to jsp files inside /views
|
|
|
*/
|
|
|
@@ -35,11 +51,19 @@ public class WebConfig implements WebMvcConfigurer {
|
|
|
public ViewResolver viewResolver() {
|
|
|
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
|
|
|
viewResolver.setViewClass(JstlView.class);
|
|
|
+ viewResolver.setAttributesMap(jspProperties);
|
|
|
viewResolver.setPrefix("/views/");
|
|
|
viewResolver.setSuffix(".jsp");
|
|
|
return viewResolver;
|
|
|
}
|
|
|
|
|
|
+ @Bean
|
|
|
+ public static PropertiesFactoryBean jspProperties() {
|
|
|
+ PropertiesFactoryBean bean = new PropertiesFactoryBean();
|
|
|
+ bean.setLocation(new ClassPathResource("jsp.properties"));
|
|
|
+ return bean;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
|
|
// Allow /static/** to access js/css files
|