formatting cleanup
This commit is contained in:
parent
2499509ada
commit
2c9fa6a010
@ -18,7 +18,7 @@ public class MySimpleUrlAuthenticationSuccessHandler implements AuthenticationSu
|
|||||||
private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
|
private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException {
|
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException {
|
||||||
handle(request, response, authentication);
|
handle(request, response, authentication);
|
||||||
HttpSession session = request.getSession(false);
|
HttpSession session = request.getSession(false);
|
||||||
if (session != null) {
|
if (session != null) {
|
||||||
@ -39,9 +39,9 @@ public class MySimpleUrlAuthenticationSuccessHandler implements AuthenticationSu
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected String determineTargetUrl(Authentication authentication) {
|
protected String determineTargetUrl(Authentication authentication) {
|
||||||
|
|
||||||
return "/home.html";
|
return "/home.html";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void clearAuthenticationAttributes(HttpServletRequest request) {
|
protected void clearAuthenticationAttributes(HttpServletRequest request) {
|
||||||
|
@ -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;
|
||||||
@ -42,9 +40,9 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
|
|||||||
@Override
|
@Override
|
||||||
public void addViewControllers(final ViewControllerRegistry registry) {
|
public void addViewControllers(final ViewControllerRegistry registry) {
|
||||||
super.addViewControllers(registry);
|
super.addViewControllers(registry);
|
||||||
registry.addViewController("/login.html");
|
registry.addViewController("/login.html");
|
||||||
registry.addViewController("/home.html");
|
registry.addViewController("/home.html");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ -55,23 +53,21 @@ public class MvcConfig extends WebMvcConfigurerAdapter {
|
|||||||
bean.setSuffix(".jsp");
|
bean.setSuffix(".jsp");
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@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/");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import org.springframework.context.annotation.ImportResource;
|
|||||||
@ImportResource({ "classpath:webSecurityConfig.xml" })
|
@ImportResource({ "classpath:webSecurityConfig.xml" })
|
||||||
public class SecSecurityConfig {
|
public class SecSecurityConfig {
|
||||||
|
|
||||||
public SecSecurityConfig() {
|
public SecSecurityConfig() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,22 +14,19 @@ 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 {
|
||||||
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
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