Commit bb5056ed authored by DESKTOP-FI5PFC1\tevir's avatar DESKTOP-FI5PFC1\tevir

TOP画面ルーティング途中

parent 2c83df65
......@@ -21,23 +21,23 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter{
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.mvcMatchers("/limited/login").permitAll()
.mvcMatchers("/limited/admin/**").hasRole("ADMIN")
.anyRequest().authenticated()
.mvcMatchers("/limited/login").permitAll() //ログイン前でもアクセス可能なURLの指定
.mvcMatchers("/limited/admin/**").hasRole("ADMIN")//ADMIN権限のユーザーのみアクセスできるURLの指定
.anyRequest().authenticated()//ログイン前は他のアドレスにログインできないよう指定
.and()
.formLogin()
.loginProcessingUrl("/login")
.loginPage("/limited/login")
.defaultSuccessUrl("/limited/top", true)
.usernameParameter("email").passwordParameter("password")
.loginProcessingUrl("/login") //ログイン処理でpostするURL
.loginPage("/limited/login") //ログインページのURL
.defaultSuccessUrl("/limited/top", true) //ログイン成功時のURL
.usernameParameter("email").passwordParameter("password") //ログインのパラメーター指定
.and()
.logout()
.invalidateHttpSession(true)
.deleteCookies("JSESSIONID")
.logoutSuccessUrl("/limited/login");
.deleteCookies("JSESSIONID") //ログアウト時キャッシュを削除する処理
.logoutSuccessUrl("/limited/login"); //ログアウト後に表示するURL
}
@Bean
@Bean //パスワードのハッシュか
PasswordEncoder passwordEncoder(){
return new Pbkdf2PasswordEncoder();
}
......
package com.example.web;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.example.domain.User;
import com.example.service.LoginUser;
@Controller
@RequestMapping("limited")
public class EcsiteController {
//トップ画面遷移(現在のログインユーザーデータもmodelに格納済み)
@GetMapping("top")
public String top(Model model, @AuthenticationPrincipal LoginUser userDetails) {
User user = userDetails.getUser();
model.addAttribute("user", user);
return "index";
}
@GetMapping("list")
public String list() {
return "Hello world";
}
}
<!DOCTYPE html>
<html class="no-js" lang="ja">
<html class="no-js" lang="ja" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
......@@ -74,6 +74,7 @@
</ul>-->
<!--</div> /.navbar-collapse -->
<!--</div> /.container -->
</div>
</nav>
</header>
......@@ -83,7 +84,7 @@
<div class="col-md-12">
<form class="form-inline col-md-12 wow fadeInDown animated">
<div class="form-group">
<input type="email" class="form-control subscribe" id="email" placeholder="Search...">
<input type="email" class="form-control subscribe" id="email" placeholder="Search..."/>
<button class="suscribe-btn" ><i class="pe-7s-search"></i></button>
</div>
</form><!-- end /. form -->
......@@ -104,27 +105,27 @@
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="images/スニーカー1.jpg" width="1648" height="600" alt="">
<img src="images/スニーカー1.jpg" width="1648" height="600" alt=""/>
<div class="carousel-caption">
<h2>LIMITED SHOES</h2>
<h3><Span>SALE SITE</Span></h3>
<a th:href="http://localhost:8080/limited/list">Go To</a>
<a th:href="@{http://localhost:8080/limited/list}">Go To</a>
</div>
</div>
<div class="item">
<img src="images/スニーカー1.jpg" width="1648" height="600" alt="">
<img src="images/スニーカー1.jpg" width="1648" height="600" alt=""/>
<div class="carousel-caption">
<h2>LIMITED SHOES</h2>
<h3><Span>SALE SITE</Span></h3>
<a th:href="http://localhost:8080/limited/list">Go To</a>
<a th:href="@{http://localhost:8080/limited/list}">Go To</a>
</div>
</div>
<div class="item ">
<img src="images/スニーカー1.jpg" width="1648" height="600" alt="">
<img src="images/スニーカー1.jpg" width="1648" height="600" alt=""/>
<div class="carousel-caption">
<h2>LIMITED SHOES</h2>
<h3><Span>SALE SITE</Span></h3>
<a th:href="http://localhost:8080/limited/list">Go To </a>
<a th:href="@{http://localhost:8080/limited/list}">Go To </a>
</div>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment