formatting cleanup
This commit is contained in:
parent
2499509ada
commit
2c9fa6a010
@ -1,9 +1,7 @@
|
|||||||
package org.baeldung.spring;
|
package org.baeldung.spring;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@ -58,19 +56,17 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
//For examples using Spring 4.1.0
|
// For examples using Spring 4.1.0
|
||||||
if((env.getProperty("resource.handler.conf")).equals("4.1.0")){
|
if ((env.getProperty("resource.handler.conf")).equals("4.1.0")) {
|
||||||
registry.addResourceHandler("/js/**").addResourceLocations("/js/").setCachePeriod(3600).resourceChain(true).addResolver(new GzipResourceResolver()).addResolver(new PathResourceResolver());
|
registry.addResourceHandler("/js/**").addResourceLocations("/js/").setCachePeriod(3600).resourceChain(true).addResolver(new GzipResourceResolver()).addResolver(new PathResourceResolver());
|
||||||
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/", "classpath:/other-resources/").setCachePeriod(3600).resourceChain(true).addResolver(new PathResourceResolver());
|
registry.addResourceHandler("/resources/**").addResourceLocations("/resources/", "classpath:/other-resources/").setCachePeriod(3600).resourceChain(true).addResolver(new PathResourceResolver());
|
||||||
registry.addResourceHandler("/files/**").addResourceLocations("file:/Users/Elena/").setCachePeriod(3600).resourceChain(true).addResolver(new PathResourceResolver());
|
registry.addResourceHandler("/files/**").addResourceLocations("file:/Users/Elena/").setCachePeriod(3600).resourceChain(true).addResolver(new PathResourceResolver());
|
||||||
registry.addResourceHandler("/other-files/**").addResourceLocations("file:/Users/Elena/").
|
registry.addResourceHandler("/other-files/**").addResourceLocations("file:/Users/Elena/").setCachePeriod(3600).resourceChain(true).addResolver(new GzipResourceResolver());
|
||||||
setCachePeriod(3600).resourceChain(true).addResolver(new GzipResourceResolver());
|
|
||||||
}
|
}
|
||||||
//For examples using Spring 4.0.7
|
// For examples using Spring 4.0.7
|
||||||
else if ((env.getProperty("resource.handler.conf")).equals("4.0.7")){
|
else if ((env.getProperty("resource.handler.conf")).equals("4.0.7")) {
|
||||||
registry.addResourceHandler("/resources/**").addResourceLocations("/", "/resources/", "classpath:/other-resources/");
|
registry.addResourceHandler("/resources/**").addResourceLocations("/", "/resources/", "classpath:/other-resources/");
|
||||||
registry.addResourceHandler("/files/**")
|
registry.addResourceHandler("/files/**").addResourceLocations("file:/Users/Elena/");
|
||||||
.addResourceLocations("file:/Users/Elena/");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,12 +15,9 @@ import org.springframework.web.context.request.WebRequest;
|
|||||||
@Controller
|
@Controller
|
||||||
public class HomeController {
|
public class HomeController {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
Environment env;
|
Environment env;
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = "/home", method = RequestMethod.GET)
|
@RequestMapping(value = "/home", method = RequestMethod.GET)
|
||||||
public String showHome(WebRequest request, Model model, Locale locale) throws IOException {
|
public String showHome(WebRequest request, Model model, Locale locale) throws IOException {
|
||||||
|
|
||||||
@ -28,7 +25,7 @@ public class HomeController {
|
|||||||
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
|
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
|
||||||
|
|
||||||
String formattedDate = dateFormat.format(date);
|
String formattedDate = dateFormat.format(date);
|
||||||
model.addAttribute("serverTime", formattedDate );
|
model.addAttribute("serverTime", formattedDate);
|
||||||
return "home";
|
return "home";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user