0
我试图按照此作为参考Serving Static content in SpringBoot错误而从JSP移动HTML表单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。
如果我只是把在的index.html该内容没有控制上下文句柄。该页面加载得很好。百里香不会抛出任何错误。
感谢varren得到
SAXParseException: Attribute "type" was already specified for element
。我也发现了这个问题,但无法理解它背后的原因。你提到的正确答案是有道理的。 – Acewin