나는 원래이 기사에서 Thymeleaf에 대해 계속 글을 쓰려고 계획했다. 나는 많은 콘텐츠가 있다는 것을 보았고 일주일 안에 그것을 끝내지 못할 수도 있습니다. Baidu Online의 컨트롤러 및 기타 콘텐츠로부터 가치를 얻을 수 있으므로 SpringBoot Integrated JSP를 작성했습니다. Thymeleaf 또는 JSP이든 실제로는 계층화 된 아이디어의 표현입니다.
1. 종속성을 소개합니다
이전 블로그의 데모를 사용하여이를 기반으로 수정합니다. 이번에는 JSP를 통합하므로 먼저 JSP 의존성을 소개해야합니다. 여기에서 이전 블로그에 추가 된 Thymeleaf를 제거해야합니다.
<pectionency> <groupid> org.apache.tomcat.embed </groupid> <artifactid> tomcat-embed-jasper </artifactid> </scope> </spectency> <peleponemency> <groupId> javax.servlet </groupId> <artifactid> jstl> suffort> cuspet> cuspet> <pectionency> <groupid> javax.servlet </groupid> <artifactid> javax.servlet-api </artifactid> <scope> 제공 </scope> </fectionency>
2. JSP 페이지를 만듭니다
JSP와 통합되므로 JSP 페이지는 필수 불가결합니다. 여기에 JSP 페이지 로그인을 넣습니다. JSP의 컨트롤러에서 가변 값을 얻으십시오.
<%@ page language = "java"contmenttype = "text/html; charset = utf-8"pageencoding = "utf-8"%> <! doctype html public "-// w3c // dtml 4.01 Transitional // en" "http://www.w3.org/tr/tr/html4/loose.dtd"> html> html> http-quiv ="content-type "content ="text/html; charset = utf-8 "> <title> 삽입 제목 여기 </title> </head> <hod> 이름 : $ {name} <br> </body> </html>3. 구성
Application.Properties에서보기의 접두사 접미사를 구성하십시오.
spring.mvc.view.prefix =/view/spring.mvc.view.suffix = .jsp
4. 컨트롤러를 만듭니다
존재하다
package com.example.demo; import org.springframework.steretype.controller; import org.springframework.ui.model; import org.springframework.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmapped (@controller@rogetod; 클래스 로그인 {@requestmapping (value = "/login.do",Method = requestMethod.get) public String Hello (모델 모델) {model.addattribute ("name ","cuiyw "); "로그인"을 반환합니다. }}V. 테스트
http : // localhost : 8080/login/login.do를 입력하십시오
위는이 기사의 모든 내용입니다. 모든 사람의 학습에 도움이되기를 바랍니다. 모든 사람이 wulin.com을 더 지원하기를 바랍니다.