Login and logout works together with context root

This commit is contained in:
Nanne Baars 2016-04-10 14:56:27 +02:00
parent d0acfc00c0
commit 289da771c9
2 changed files with 4 additions and 3 deletions

View File

@ -24,13 +24,14 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
security.and() security.and()
.formLogin() .formLogin()
.loginPage("/login") .loginPage("/login")
.defaultSuccessUrl("/welcome.mvc") .defaultSuccessUrl("/welcome.mvc", true)
.usernameParameter("username") .usernameParameter("username")
.passwordParameter("password") .passwordParameter("password")
.permitAll(); .permitAll();
security.and() security.and()
.logout() .logout()
.permitAll(); .permitAll();
} }
@Autowired @Autowired

View File

@ -42,7 +42,7 @@
<header id="header"> <header id="header">
<!--logo start--> <!--logo start-->
<div class="brand"> <div class="brand">
<a href="${pageContext.request.contextPath}/welcome.mvc" class="logo"><span>Web</span>Goat</a> <a th:href="@{/welcome.mvc}" class="logo"><span>Web</span>Goat</a>
</div> </div>
<!--logo end--> <!--logo end-->
<div class="toggle-navigation toggle-left"> <div class="toggle-navigation toggle-left">
@ -60,7 +60,7 @@
<i class="fa fa-user"></i> <span class="caret"></span> <i class="fa fa-user"></i> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu dropdown-menu-left"> <ul class="dropdown-menu dropdown-menu-left">
<li role="presentation"><a role="menuitem" tabindex="-1" href="/login?logout">Logout</a></li> <li role="presentation"><a role="menuitem" tabindex="-1" th:href="@{/login(logout)}">Logout</a></li>
<li role="presentation" class="divider"></li> <li role="presentation" class="divider"></li>
<li role="presentation" class="disabled"><a role="menuitem" tabindex="-1" href="#">User: <span <li role="presentation" class="disabled"><a role="menuitem" tabindex="-1" href="#">User: <span
th:text="${#authentication.name}"></span></a> th:text="${#authentication.name}"></span></a>