Thymeleaf 소개
간단히 말해서, Thymeleaf는 속도 및 프리 마커와 유사한 템플릿 엔진으로 JSP를 완전히 대체 할 수 있습니다. 다른 템플릿 엔진과 비교하여 다음은 다음과 같은 세 가지 매력적인 기능을 가지고 있습니다.
1. Thymeleaf는 네트워크의 유무에 관계없이 환경에서 실행할 수 있습니다. 즉, 아티스트는 브라우저에서 페이지의 정적 효과를 볼 수 있으며 프로그래머가 서버의 데이터로 동적 페이지 효과를 볼 수 있습니다. 이는 HTML 프로토 타입을 지원 한 다음 HTML 태그에 추가 속성을 추가하여 템플릿 + 데이터의 디스플레이 메소드를 달성하기 때문입니다. 브라우저가 HTML을 해석하면 정의되지 않은 태그 속성이 무시되므로 Thymeleaf의 템플릿을 정적으로 실행할 수 있습니다. 데이터가 페이지로 반환되면 Thymeleaf 태그는 정적 컨텐츠를 동적으로 교체하여 페이지 표시가 동적으로 만듭니다.
2. Thymeleaf가 상자 밖으로 나왔습니다. 표준과 스프링 표준의 두 가지 방언을 제공합니다. 템플릿을 직접 적용하여 JSTL 및 OGNL 표현 효과를 달성하여 매일 템플릿, JSTL 및 변경 사항 변경에 어려움을 피할 수 있습니다. 동시에 개발자는 커스텀 방언을 확장하고 만들 수 있습니다.
3. Thymeleaf는 SpringMVC와 완벽하게 통합되는 스프링 표준 방언 및 옵션 모듈을 제공하여 양식 바인딩, 속성 편집기, 국제화 및 기타 기능을 빠르게 구현할 수 있습니다.
양식 방법 업로드 :
// html : <form enctype = "multipart/form-data"method = "post"action = "/sell/imageupload"> <div> <버튼 유형 = "button"data-dismiss = "modal"aria-hidden = "true"> </button> <h4 id = "mymodallabel"> edit goods <inpore <inpore <inpore <inpore </h4> id = "edit_name"value = "$ {goods.name}" "name ="name "/> </div> <div> <label> 코드 : </label> <input id ="edit_sn "name ="sn "value ="$ {goods.sn} "/> </div> <labe> weight : </label> <input id ="edit_ "" "" "" "" " value = "$ {goods.weight}"/> </div> <div> <label> MarketPrice : </label> <input id = "edit_marketprice"name = "MarketPrice"value = "$ {goods.marketPrice}"/> </div> <label> shopPrice : <input id = "edit_shop" "shopprice" value = "$ {goods.shopprice}"/> </div> <div> <label> 단위 : </label> <input id = "edit_unit"name = "unit"value = "$ {goods.unit}"/> </div> <div> <div> <label> 숫자 : </label> <input id = "edit_number"name = "number"$ {number} "". </div> <div> <!-<form enctype = "multipart/form-data"method = "post"action = "/sell/imageupload"> <입력 ype = "hidden"id = "edit_goods_sn"name = "sn"value = "$ {goods.sn}"/>-> image <input type = "id ="id "id"id "id"id "id"id " 유형 = "value ="upload "/> <!-</form>->-> </div> </div> <div> <버튼 유형 ="버튼 "Data-dismiss ="modal "> close </button> <input type ="id = "edit_save"value = "제출"> value "/savestmapping (value =/savestmapping). requestMethod.post) public string savegoodspage (@requestparam (value = "id", required = false) 문자열 id,@requestParam (value = "name", resight) 문자열 이름,@requestParam (value = "sn", 필수 = 거짓) 문자열 sn, @requestparam (value = "number", resight) string number (value =@weeight) = "MarketPrice", 필수 = 거짓) String MarketPrice, @requestParam (value = "shopPrice", Question = false) 문자열 shopPrice, @requestParam (value = "init", resight = false) 문자열 단위, @RequestParam (value = "detail" ", @requestParam (value ="file ") multipartFile 파일) {! if (!) bufferedOutputStream out = new BufferedOutputStream (새 파일 OutputStream (새 파일 ( "src/main/resources/static/images/product/" + sn + ".jpg"))); // 디렉토리 out.write (file.getBytes ())에 이미지를 저장합니다. out.flush (); out.close (); String filename = "/// images /// upbution ///" + sn + ".jpg"; /user.settupian(filename); //userrepository.save(user) ;//add user*/} catch (filenotfoundexception e) {e.printstacktrace (); "업로드 오류"를 반환합니다. + e.getMessage (); } catch (ioexception e) {e.printstacktrace (); "업로드 오류" + e.getMessage ()를 반환합니다. }} //... 다른 작업}보충 : 가변 표현식과 별표 표현식 사이에 차이가 있습니까?
맥락을 고려하지 않고 둘 사이에는 차이가 없습니다. 별표 구문 평가는 선택된 객체가 아니라 선택된 개체가 아니라 선택된 객체에 표현됩니다. 다음과 같이 부모 태그의 값입니다.
<div th : object = "$ {session.user}"> <p> 이름 : <span th : text = "*{firstName}"> sebastian </span </span>. Th : text = "*{국적}"> 토성 </span>. </p> </div>이것은 정확히 다음과 같습니다.
<div th : object = "$ {session.user}"> <p> 이름 : <span th : text = "$ {session.user.firstname}"> sebastian </span>. </p> <p> 성 : <span = "$ {session.user.lastname}"> Pepper </span>. Th : text = "$ {session.user.nationality}"> Saturn </span>. </p> </div>물론 달러 표시와 별표 구문을 혼합 할 수 있습니다.
<div th : object = "$ {session.user}"> <p> 이름 : <span th : text = "*{firstName}"> sebastian </span </span>. Th : text = "*{국적}"> 토성 </span>. </p> </div>요약
위의 것은 스프링 부트 Thymeleaf 이미지를 귀하에게 업로드하기위한 작동 단계입니다. 나는 그것이 당신에게 도움이되기를 바랍니다. 궁금한 점이 있으면 메시지를 남겨 주시면 편집자가 제 시간에 답장을 드리겠습니다. Wulin.com 웹 사이트를 지원해 주셔서 대단히 감사합니다!