구디아카데미/JAVA

1030 Spring 기본

COCO_develop 2024. 10. 30. 13:59
package com.example.demo;

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

@Controller
public class HelloController {
	
	@GetMapping("/hello")
	public String hello() {
		return "a";
	}
}

∆ ∇ 같은 의미

@WebServlet("/hello")
public class FrontServlet extends HttpServlet{
	void doget(request,response) {
		String s = this.hello(reqeust,response);
		RequestDispatcher(prifix + s + seffix).forward(request,response);
	}
	String hello(request,response) {
		return "a";
	}
}

prifix + s + seffix == /WEB-INF/view/a.jsp

 

 

Mybatis XML Mapper -> 쿼리 파일

 - 원래 interface 파일 하나로 사용 가능하지만 쿼리가 길어지면 가독성이 떨어져 쿼리만 입력하는 파일을 따로 만든 것

 - namespace: interface 이름

 - resultType: 반환타입

<mapper namespace="com.example.sakila.mapper.CountryMapper">
	<select id="selectCountryList" resultType="com.example.sakila.vo.Country">
		SELECT 
			country_id countryId
			, country
			,last_update lastUpdate 
		FROM country
	</select>
</mapper>

 

 

* xml 오류 날때 - 그냥 버그

 - 파일 만들자마자 오류나는건 버그일 가능성 높음

 - 파일 고치는건 웬만하면 안하는 쪽으로

체크했다가 다시 풀어보기

 

 

* 디폴트 브라우저 바꾸기

Window > Preferenses > Web Browser 

 

 

* jsp 파일 templates 수정

Window > Preferenses > JSP files > Templates

 - Name : New JSP File(html 5)

<%@ page language="java" contentType="text/html; charset=${encoding}" pageEncoding="${encoding}"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://code.jquery.com/jquery-3.7.1.js" integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4=" crossorigin="anonymous"></script>
<meta charset="${encoding}">
<title></title>
</head>

 

 - taglib,bootstrap, jquery CDN 추가