0
thymeleaf 정의를 기반으로 태그를 평가하지 않는다, 나는 thymeleaf이 구성이 있습니다봄 부팅 내 현재의 봄 부팅 응용 프로그램에서 방언
@Configuration
public class Thymeleaf {
@Bean
public SpringTemplateEngine templateEngine() {
SpringTemplateEngine engine = new SpringTemplateEngine();
final Set<IDialect> dialects = new HashSet<IDialect>();
dialects.add(new SpringSecurityDialect());
dialects.add(new FormDialect());
dialects.add(new FieldDialect());
engine.setDialects(dialects);
return engine;
}
}
을하고 나는이 두 방언 추가
을 org.store.custom.thymeleaf.dialect.FormDialect.java
public class FormDialect extends AbstractDialect {
public FormDialect() {
super();
}
//
// All of this dialect's attributes and/or tags
// will start with 'form:'
//
public String getPrefix() {
return "form";
}
//
// The processors.
//
@Override
public Set<IProcessor> getProcessors() {
final Set<IProcessor> processor = new HashSet<IProcessor>();
processor.add(new Form());
return processor;
}
}
org.store.custom.thymeleaf.dialect.FieldDialect.java
public class FieldDialect extends AbstractDialect {
public FieldDialect() {
super();
}
//
// All of this dialect's attributes and/or tags
// will start with 'field:'
//
public String getPrefix() {
return "field";
}
//
// The processors.
//
@Override
public Set<IProcessor> getProcessors() {
final Set<IProcessor> processor = new HashSet<IProcessor>();
processor.add(new Checkbox());
processor.add(new DataList());
processor.add(new Input());
processor.add(new Property());
processor.add(new Radio());
processor.add(new Select());
processor.add(new Textarea());
return processor;
}
}
하지만 내 html 페이지에서 해당 방언으로 태그를 사용하면이 태그는 일반 태그로 평가되지 않습니다. 페이지는이 같은 코드가 있습니다
<!DOCTYPE html>
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3"
xmlns:form=""
xmlns:field="">
<head>
<title>Cadastro</title>
</head>
<body>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Cadastrar <span th:text="${command.getClass().getSimpleName()}"/></h3>
</div>
<div class="panel-body">
<form:form>
<field-box th:each="item : ${command.getClass().getDeclaredFields()}">
<div th:each="item2 : ${item.getDeclaredAnnotations()}">
<div th:switch="${item2.annotationType().getSimpleName()}">
<div th:case="'Checkbox'"><field:checkbox/></div>
<div th:case="'DataList'"><field:datalist/></div>
<div th:case="'Input'"><field:input/></div>
<div th:case="'Radiobutton'"><field:radio/></div>
<div th:case="'Select'"><field:select/></div>
<div th:case="'Textarea'"><field:textarea/></div>
</div>
</div>
</field-box>
</form:form>
</div>
</div>
<script src="js/form_submit.js"></script>
<script src="js/form_valida.js"></script>
</body>
</html>
프로세서에 대한 코드하면 해당 같다 :이 순간에
public class Form extends AbstractProcessor {
@Override
public ProcessorResult doProcess(Arguments arguments,ProcessorMatchingContext context,Node node) {
Element form = new Element("form");
form.setProcessable(true);
form.setAttribute("role", "form");
form.setAttribute("class", "form");
form.setAttribute("action", "");
form.setAttribute("method", "post");
node.getParent().insertBefore(node, form);
return ProcessorResult.OK;
}
@Override
public int getPrecedence() {
return 0;
}
@Override
public IProcessorMatcher<? extends Node> getMatcher() {
return new ElementNameProcessorMatcher("form");
}
}
는 이유에 대한 내 주요 개념이 그것의 작동하지 않는 I 때문에 네임 스페이스에 올바른 값을 사용하지 마십시오. 이 값을 사용해보십시오 :
* http://form and http://field
* http://org for both
* http://org.store.custom.thymeleaf for both
* http://www.thymeleaf.org/org for both
누구나 내가 여기에서 빠진 것을 볼 수 있습니까?