Polish "Fix JSP availability check when not running as a packaged war"

Closes gh-12859
This commit is contained in:
Andy Wilkinson
2018-06-21 17:19:53 +01:00
parent 82465cf435
commit b1d8cc55fc
3 changed files with 32 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.web;
import java.io.File;
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.core.env.Environment;
@@ -38,8 +40,10 @@ public class JspTemplateAvailabilityProvider implements TemplateAvailabilityProv
ClassLoader classLoader, ResourceLoader resourceLoader) {
if (ClassUtils.isPresent("org.apache.jasper.compiler.JspConfig", classLoader)) {
String resourceName = getResourceName(view, environment);
return resourceLoader.getResource(resourceName).exists() ||
resourceLoader.getResource("file:./src/main/webapp" + resourceName).exists();
if (resourceLoader.getResource(resourceName).exists()) {
return true;
}
return new File("src/main/webapp", resourceName).exists();
}
return false;
}