JSP 프로그래밍은 webapp 라는 특별한 디렉토리에서 진행해야 하므로 이것부터 만들어준다.
1. src/main 아래 webapp 생성
2. webapp 아래 jsp 파일 생성
3. 필요라이브러리 추가. build.gradle 에 다음 내용 추가
runtimeOnly 'org.apache.tomcat.embed:tomcat-embed-jasper:'
runtimeOnly 'jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api'
4. jsp 코딩
예제)
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
String requestName = request.getParameter("name");
String servletName = config.getServletName();
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title> JSP 기초 </title>
</head>
<body>
<h2><%= requestName %> Hello World! - TEST</h2>
<h2> 나는 <%= servletName %> 이란다!!! - TEST</h2>
</body>
</html>
5. 테스트...URL 에 jsp 파일명을 바로 쓰고 접근
http://localhost:9090/HelloJsp.jsp?name=%22%EB%82%98%EB%82%98%22
'IT > Spring Boot' 카테고리의 다른 글
spring boot에 logback 적용하기 (0) | 2022.10.08 |
---|---|
Axis 강좌 (0) | 2022.09.29 |
SpringBoot프로젝트에 Servlet 프로그래밍 추가 하기 (0) | 2022.09.29 |
Axis 관련 글 모음...(WSDL 관련 라이브러리) (0) | 2022.09.29 |
Springboot excel 파일 다운로드 기능 예제 (0) | 2022.09.26 |
댓글