|
|
@ -17,6 +17,7 @@
|
|
|
|
package org.springframework.boot.autoconfigure.web.servlet;
|
|
|
|
package org.springframework.boot.autoconfigure.web.servlet;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.File;
|
|
|
|
|
|
|
|
import java.security.AccessControlException;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
|
|
|
|
import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
|
|
|
|
import org.springframework.core.env.Environment;
|
|
|
|
import org.springframework.core.env.Environment;
|
|
|
@ -30,6 +31,7 @@ import org.springframework.util.ClassUtils;
|
|
|
|
* @author Andy Wilkinson
|
|
|
|
* @author Andy Wilkinson
|
|
|
|
* @author Stephane Nicoll
|
|
|
|
* @author Stephane Nicoll
|
|
|
|
* @author Madhura Bhave
|
|
|
|
* @author Madhura Bhave
|
|
|
|
|
|
|
|
* @author Artsiom Yudovin
|
|
|
|
* @since 1.1.0
|
|
|
|
* @since 1.1.0
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class JspTemplateAvailabilityProvider implements TemplateAvailabilityProvider {
|
|
|
|
public class JspTemplateAvailabilityProvider implements TemplateAvailabilityProvider {
|
|
|
@ -38,12 +40,18 @@ public class JspTemplateAvailabilityProvider implements TemplateAvailabilityProv
|
|
|
|
public boolean isTemplateAvailable(String view, Environment environment,
|
|
|
|
public boolean isTemplateAvailable(String view, Environment environment,
|
|
|
|
ClassLoader classLoader, ResourceLoader resourceLoader) {
|
|
|
|
ClassLoader classLoader, ResourceLoader resourceLoader) {
|
|
|
|
if (ClassUtils.isPresent("org.apache.jasper.compiler.JspConfig", classLoader)) {
|
|
|
|
if (ClassUtils.isPresent("org.apache.jasper.compiler.JspConfig", classLoader)) {
|
|
|
|
|
|
|
|
|
|
|
|
String resourceName = getResourceName(view, environment);
|
|
|
|
String resourceName = getResourceName(view, environment);
|
|
|
|
if (resourceLoader.getResource(resourceName).exists()) {
|
|
|
|
if (resourceLoader.getResource(resourceName).exists()) {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
return new File("src/main/webapp", resourceName).exists();
|
|
|
|
return new File("src/main/webapp", resourceName).exists();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (AccessControlException ex) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|