Я использую Thymeleaf.Thymeleaf при синтаксисе: «@ {/}» возвращается пустым, если я включаю ResourceUrlEncodingFilter
Этот шаблон:
<a th:href="@{/}">a</a>
производит этот HTML:
<a href="/">a</a>
Это то, что я ожидал.
Я поместил компонент ResourceUrlEncodingFilter, чтобы попробовать ContentVersionStrategy в расширенном классе WebMvcConfigurerAdapter.
@Bean
public ResourceUrlEncodingFilter resourceUrlEncodingFilter() {
return new ResourceUrlEncodingFilter();
}
Производимый HTML обратился к:
<a href="">a</a>
Значение HREF пусто. Надеюсь, что href есть «/», даже если я поставлю компонент ResourceUrlEncodingFilter. th:href="@{/a}"
превращается в href="/a"
в обоих случаях.
Я сделал что-то не так?
спасибо.
UPDATE:
Это мой build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'io.spring.gradle:dependency-management-plugin:0.5.1.RELEASE'
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.3.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
apply plugin: 'io.spring.dependency-management'
version = '1.0'
jar {
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version
}
}
repositories {
mavenCentral()
}
dependencyManagement {
imports {
mavenBom 'io.spring.platform:platform-bom:1.1.2.RELEASE'
}
}
dependencies {
compile('org.webjars:bootstrap:3.3.1')
compile('org.webjars:knockout:3.2.0')
compile('org.webjars:momentjs:2.9.0')
compile('org.webjars:numeral-js:1.5.3-1')
compile('org.webjars:underscorejs:1.7.0-1')
compile('org.webjars:sugar:1.4.1')
compile('org.webjars:jqplot:1.0.8r1250')
compile('org.webjars:jquery-cookie:1.4.1-1')
compile("org.springframework.boot:spring-boot-starter-actuator")
compile("org.springframework.boot:spring-boot-starter-batch")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.boot:spring-boot-starter-security")
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-tomcat")
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-starter-test")
compile("org.springframework:spring-context-support") // this is for mail
compile('commons-codec:commons-codec')
compile("commons-io:commons-io")
compile('com.google.guava:guava')
compile('org.hibernate:hibernate-validator')
compile("com.sun.mail:javax.mail")
compile('mysql:mysql-connector-java')
compile("org.yaml:snakeyaml")
compile("org.apache.commons:commons-lang3:3.2")
compile('com.amazonaws:aws-java-sdk:1.9.4')
compile('net.sf.supercsv:super-csv:2.2.0')
compile('edu.vt.middleware:vt-password:3.1.2')
}
test {
//systemProperties 'property': 'value'
systemProperties 'spring.profiles.active': 'unittest'
systemProperties 'MAIL_PROP': 'mail.properties'
systemProperties 'user.timezone': 'UTC'
}
uploadArchives {
repositories {
flatDir {
dirs 'repos'
}
}
}
какой весенней версии вы используете? вы могли бы поделиться своим Webconfig/web.xml? вы используете простой Spring Framework или Spring Boot? –
Я использую io.spring.platform: platform-bom: 1.1.2.RELEASE с градиентом. Он будет включать spring-webmvc 4.1.6.RELEASE. Я могу показать мой build.gradle. Спасибо, что ответили. –