Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 포트포워딩
- node js
- 프론트엔드
- 수익 자동화
- Tailwind Css
- 개발자 수익화
- 리엑트
- Flutter
- 자바
- java
- Spring
- 자동화 수익
- 1인개발자
- 호주워킹홀리데이
- 1인 개발
- SPRING 회원 관리 기능
- 리엑트 라우터
- Next.js
- 호주
- 간편한요리
- 수익화
- 일러스트
- MCP
- 개발자
- Firebase
- 1인 개발자
- 간단한 요리
- mcp 서버
- spring 세팅
- 웹개발자
Archives
- Today
- Total
IT 세상에서 살아남기
SPRING(13) 회원 관리 기능 구현_3 본문
반응형
데이터베이스 연동에 필요한 작업이 끝났으니 이제는 기본 경로를 설정하는 세팅을 하도록 하겠습니다.
1. 먼저 해당 웹서비스를 이용하기 위해서 기본적인 접속을 했을때 생성되는 home이 아니라 index를 만들어서 관리를 해줍니다.
package com.care.member;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 org.springframework.web.bind.annotation.RequestMethod;
/**
* Handles requests for the application home page.
*/
@Controller
public class HomeController {
private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
/**
* Simply selects the home view to render by returning its name.
*/
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
logger.info("Welcome home! The client locale is {}.", locale);
Date date = new Date();
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
String formattedDate = dateFormat.format(date);
model.addAttribute("serverTime", formattedDate );
return "home";
}
@GetMapping("/index")
public String index() {
return "/index";
}
}
기본적으로 프로잭트를 만들게 되면 homeController 가 생성되는데 index 를 만들어서 index.jsp를 만들어 주고 메인페이지를 구현합니다.
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="contextPath" value="${pageContext.request.contextPath }" />
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>메인 페이지 입니다.</h1>
<a href="${contextPath }/member/loginForm">로그인 하기</a>
</body>
</html>
그러면 /index의 경로를 찍게 되면 정상적으로 메인페이지가 나오는 것을 알 수 있습니다.
반응형
'spring' 카테고리의 다른 글
SPRING(15) 회원 관리 기능 구현_회원가입 기능 (0) | 2022.01.26 |
---|---|
SPRING(14) 로그인 팝업창으로 만들기 (0) | 2022.01.26 |
SPRING(12) 회원 관리 기능 구현_2(데이터베이스 설계) (0) | 2022.01.25 |
SPRING(11) 회원 관리 기능 구현_1 (0) | 2022.01.24 |
SPRING(10) 만약 다음 주소 API를 쓰는데 데이터베이스가 하나라면? (0) | 2022.01.24 |