This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.springsource.examples.spring31.web.config; | |
| // ... | |
| @Configuration | |
| @EnableWebMvc | |
| @ComponentScan(basePackageClasses = { ViewController.class, CustomerService.class }) | |
| public class WebMvcConfiguration extends WebMvcConfigurerAdapter { | |
| @Bean | |
| public ViewResolver getViewResolver() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.springsource.examples.spring31.web; | |
| import org.springframework.stereotype.Controller; | |
| import org.springframework.ui.Model; | |
| import org.springframework.util.StringUtils; | |
| import org.springframework.web.bind.annotation.RequestMapping; | |
| import org.springframework.web.bind.annotation.RequestMethod; | |
| import org.springframework.web.bind.annotation.RequestParam; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.springsource.examples.spring31.web.config; | |
| // ... | |
| @Configuration | |
| @EnableWebMvc | |
| @ComponentScan(basePackageClasses = {ViewController.class, CustomerService.class}) | |
| public class WebMvcConfiguration extends WebMvcConfigurerAdapter { | |
| // ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.springsource.examples.spring31.web.config; | |
| // ... | |
| @Configuration | |
| @EnableWebMvc | |
| @ComponentScan(basePackageClasses = {ViewController.class, CustomerService.class}) | |
| public class WebMvcConfiguration extends WebMvcConfigurerAdapter { | |
| // ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.springsource.examples.spring31.web.config; | |
| // ... | |
| @Configuration | |
| @EnableWebMvc | |
| @ComponentScan(basePackageClasses = {ViewController.class, CustomerService.class}) | |
| public class WebMvcConfiguration extends WebMvcConfigurerAdapter { | |
| // ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %> | |
| <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> | |
| <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> | |
| <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @ModelAttribute | |
| public SignInAttempt signInAttempt(@RequestParam String username, @RequestParam String password) { | |
| return new SignInAttempt(username, password); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @RequestMapping(method = RequestMethod.GET) | |
| public String showSignInPage() { | |
| return SIGNIN; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @NotEmpty | |
| private String username; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @RequestMapping(method = RequestMethod.POST) | |
| public String signin(@ModelAttribute @Valid SignInAttempt signInAttempt, BindingResult result, Model model) throws Throwable { | |
| if (!result.hasErrors()) { | |
| User user = this.userService.login(signInAttempt.getUsername(), signInAttempt.getPassword()); | |
| if (user != null) { | |
| model.addAttribute(USER_OBJECT_KEY, user); | |
| return "redirect:/crm/profile.html"; | |
| } else { | |
| result.reject("login.invalid", "The email and password did not match any known records. Please attempt your signin again."); |