I'm not sure if I know about the subject matter well enough to correctly ask the question.
Anyways, after login, I want to redirect to a url with the username in the url path. How am I able to do that?
For example, someone logs in with the user name "bmarkham". I want to redirect after login to www.website.com/bmarkham
Here is my spring-security.xml
<form-login login-page="/login" default-target-url="/welcome/"
authentication-failure-url="/login?error" username-parameter="username"
password-parameter="password" login-processing-url="/auth/login_check" />
I"ve tried messing with default-target-url and nothing really works.
Here is my Controller
@RequestMapping(value = "/login", method = RequestMethod.GET)
public ModelAndView login(@RequestParam(value = "error", required = false) String error,
@RequestParam(value = "logout", required = false) String logout) {
ModelAndView model = new ModelAndView();
if (error != null) {
model.addObject("error", "Invalid username and password");
}
model.addObject("msg", "This is a message and stuff");
return model;
}
@RequestMapping(value = { "/welcome/{userName}", "/welcome" }, method = RequestMethod.GET, produces = "application/json")
public User welcome(@PathVariable String userName) {
User user = new User();
user.setEmail(userName + "@something.com");
user.setUsername(userName);
return user;
}