Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring mvc Thymeleaf在语法上:“quot@{/}";如果包含ResourceUrlEncodingFilter,则返回空_Spring Mvc_Thymeleaf - Fatal编程技术网

Spring mvc Thymeleaf在语法上:“quot@{/}";如果包含ResourceUrlEncodingFilter,则返回空

Spring mvc Thymeleaf在语法上:“quot@{/}";如果包含ResourceUrlEncodingFilter,则返回空,spring-mvc,thymeleaf,Spring Mvc,Thymeleaf,我用的是百里香 此模板: <a th:href="@{/}">a</a> 生成的html变成: <a href="">a</a> Spring Boot为静态web资源位置的自动配置添加了“/**”匹配器。 位置是/META-INF/resources/、/resources/、/static/和/public/ 当你在Thymeleaf模板中放入下面的html时 <a th:href="@{/}">a</a> 参数l

我用的是百里香

此模板:

<a th:href="@{/}">a</a>
生成的html变成:

<a href="">a</a>
Spring Boot为静态web资源位置的自动配置添加了“/**”匹配器。 位置是/META-INF/resources/、/resources/、/static/和/public/

当你在Thymeleaf模板中放入下面的html时

<a th:href="@{/}">a</a>
参数lookupPath由“@{/}”表示为“/”,然后:

  • 带有映射的路径将为“”
  • 路径映射将为“”
  • 已解决的问题将是“”
因此,此方法返回“”并将值设置为href=“”

在我看来,如果pathWithinMapping是“”,继续for循环似乎很好。调用chain.resolverlpath似乎不太好

谢谢,

Spring Boot为静态web资源位置的自动配置添加了“/**”匹配器。 位置是/META-INF/resources/、/resources/、/static/和/public/

当你在Thymeleaf模板中放入下面的html时

<a th:href="@{/}">a</a>
参数lookupPath由“@{/}”表示为“/”,然后:

  • 带有映射的路径将为“”
  • 路径映射将为“”
  • 已解决的问题将是“”
因此,此方法返回“”并将值设置为href=“”

在我看来,如果pathWithinMapping是“”,继续for循环似乎很好。调用chain.resolverlpath似乎不太好


谢谢,

谢谢您的详细解释和复制项目


这实际上是一个bug:请参阅,将在Spring 4.1.8和4.2.0中修复。

感谢您的详细解释和repo项目


这实际上是一个bug:请参阅,将在Spring 4.1.8和4.2.0中修复。

您使用的是哪个Spring版本?你能分享你的Webconfig/web.xml吗?您使用的是纯Spring框架还是Spring引导?我使用的是io.Spring.platform:platform bom:1.1.2.RELEASE with gradle。它将包括SpringWebMVC4.1.6.0版本。我可以展示我的身材,格雷德尔。谢谢您的回复。您使用的是哪个spring版本?你能分享你的Webconfig/web.xml吗?您使用的是纯Spring框架还是Spring引导?我使用的是io.Spring.platform:platform bom:1.1.2.RELEASE with gradle。它将包括SpringWebMVC4.1.6.0版本。我可以展示我的身材,格雷德尔。谢谢你的回复。为了绕开这个问题,我使用了“@{/}”而不是“@{/}”。逻辑上是等价的。在这种情况下,资源不应该被标记为可读的,并且应该返回null-请参阅我创建了一个示例repo项目,它向我展示了这一点:您可以在这里共享您的网络配置吗?也许您的资源位置或您正在使用的servlet容器有什么特殊之处?这可能是Spring框架中的一个bug。谢谢,我想把你的要点复述一遍,但我也不能复述。所以我反复删除了我实际项目中的一堆代码,webjar触发了这些问题。我创建的存储库汇集了精华:感谢帮助!为了绕过这个问题,我使用了“@{/}”而不是“@{/}”。逻辑上是等价的。在这种情况下,资源不应该被标记为可读的,并且应该返回null-请参阅我创建了一个示例repo项目,它向我展示了这一点:您可以在这里共享您的网络配置吗?也许您的资源位置或您正在使用的servlet容器有什么特殊之处?这可能是Spring框架中的一个bug。谢谢,我想把你的要点复述一遍,但我也不能复述。所以我反复删除了我实际项目中的一堆代码,webjar触发了这些问题。我创建的存储库汇集了精华:感谢帮助!
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'
       }
    }
}
<a th:href="@{/}">a</a>
public final String getForLookupPath(String lookupPath) {
        // -- omission --
        for(String pattern : matchingPatterns) {
            // -- omission --
            String pathWithinMapping = getPathMatcher().extractPathWithinPattern(pattern, lookupPath);
            String pathMapping = lookupPath.substring(0, lookupPath.indexOf(pathWithinMapping));
            // -- omission --
            String resolved = chain.resolveUrlPath(pathWithinMapping, handler.getLocations());
            if (resolved == null) {
                continue;
            }
            // -- omission --
            return pathMapping + resolved;

        }
        // -- omission --
}