Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

개(발)린이

String(my page) 본문

Spring

String(my page)

불도정 2023. 5. 1. 16:35

이번 시간은 로그인 후 프로필 클릭하면 내정보로 들어가는 기능을 구현해본다

먼저 MyPageController 클래스 생성

마이페이지 인터페이스와

마이페이지Impl

마이페이지 맵퍼를 만들고 my-batis-config에 매퍼를 추가하여 시작전 세팅을 하였다

 

매퍼

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper>
  <cache-ref namespace="myPageMapper"/>
</mapper>

콘픽

<mappers>
	
		<!-- 
			<mapper resource="mapper 파일경로"/>
			경로를 작성하는 기준(시작지점)은 src/main/resources 폴더
		 -->
		<mapper resource="/mappers/member-mapper.xml"/>
		<mapper resource="/mappers/myPage-mapper.xml"/>
	</mappers>

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/member/myPage")
public class MyPageController {

}

컨트롤러 맵핑이다.

 

이후에 마이페이지에서 또 다른 메뉴로 이동 가능하게 세팅먼저 해주겠다

 

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;


// /member/myPage/profile
// /member/myPage/info
// /member/myPage/changePw
// /member/myPage/secession
@Controller
@RequestMapping("/member/myPage")
public class MyPageController {
	
	// 회원 정보 조회 이동
	@GetMapping("/info")
	public String info() {
		return "member/myPage-info";
	}
	
	@GetMapping("/changePW")
	public String changePw() {
		return "member/myPage-changePw";
	}
	
	@GetMapping("/secession")
	public String secession() {
		return "member/myPage-secession";
	}
	
	@GetMapping("/profile")
	public String profile() {
		return "member/myPage-profile";
	}
	
}

클릭하면 해당 jsp로 이동 가능하게끔 만들어준 모습이다.

 

다음에 서비스를 import 해주는데 @Autowired를 사용해 의존성을 주입해준다

	@Autowired
	private MyPageService service;

 

'Spring' 카테고리의 다른 글

Spring 게시판 2  (0) 2023.05.01
Spring 게시판  (0) 2023.05.01
Spring(예외처리)  (0) 2023.04.27
Spring(회원 가입 DB 저장 - 2)  (0) 2023.04.26
Spring(회원 가입 - DB저장)  (0) 2023.04.26