나는 참고로이 작업을 수행하려고 Serving Static content in SpringBoot오류 ThymeLeaf
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.ui.Model;
/**
* Created by Eric on 11/25/2015.
*/
@org.springframework.stereotype.Controller
public class Controller {
@RequestMapping("/appPage")
public String greeting(@RequestParam(value="name", required=false, defaultValue="World") String name, Model model) {
model.addAttribute("name", name);
model.addAttribute("title", "Best Of the App");
model.addAttribute("basecontext", "Best Of the App");
return "appPage";
}
}
내 HTML 양식 내가 숨겨진 입력 필드에 값을 설정하려고
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title th:text="${title}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<p th:text="'Hello, ' + ${name} + '!'" />
<input type="hidden" type="text" id="basecontext" value='${basecontext}'/>
</body>
</html>
아래에있는 . 하지만 그건 내게 오류가 발생합니다
org.springframework.web.util.NestedServletException : 요청 처리가 실패했습니다; 예외 구문 분석 문서 : 중첩 된 예외는 org.thymeleaf.exceptions.TemplateInputException이다 템플릿 = "해 AppPage", 9 행 - 열 (33)
내가 봄에 JSP 응용 프로그램에로드하기 된이 HTML 페이지를 이동하는 것을 시도하고있다 Boot + ThymeLeaf.
Controller의 Context 핸들러없이 index.html에이 내용을 넣으면됩니다. 페이지가 잘로드됩니다. Thymeleaf는 어떤 오류도 발생시키지 않습니다.
감사 varren에
SAXParseException: Attribute "type" was already specified for element
을 받아야 XMLtype="hidden" type="text"
에 같은 이름의 속성을 가질 수 없습니다. 나도이 문제를 발견했지만 그 이유는 알 수 없었다. 당신이 언급 한 것은 정확하게 대답하고 의미가 있습니다. – Acewin