'Browse' 클릭 후 다운받았던 톰캣 경로 폴더로 설정!
Window - Preferences - 'enco'검색 후 HTML, CSS, JSP, XML 파일 등등 UTF-8로 설정
다이나믹 웹프로젝트 생성
index.JSP파일 생성
[index.jsp]<% response.sendRedirect("main.mvc"); %>
컨트롤러 생성
[HomeController.java]@WebServlet("*.mvc") public class HomeController extends HttpServlet{ private static final long serialVersionUID = 1L; //Get요청이 들어오면 여기서 처리된다!! @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // 요청한 주소를 가져오기 String url = request.getRequestURI(); //System.out.println(url); // 결과 : /ServletMVC/main.mvc if(url.contains("main.mvc")) { System.out.println("main 요청"); } else if(url.contains("test1.mvc")) { System.out.println("test1 요청"); } else if(url.contains("test2.mvc")) { System.out.println("test2 요청"); } } }
*.mvc : 모든요청주소가 끝이.mvc로 끝나면 모두 받기
main / test1 / test2 JSP파일 생성
[main.jsp]
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <h1>main.mvc</h1> </body> </html>
[test1.jsp]
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <h1>test1.mvc</h1> </body> </html>
[test2.jsp]
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Insert title here</title> </head> <body> <h1>test2.mvc</h1> </body> </html>