You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2018/10/28 09:27:11 UTC
[incubator-skywalking] 01/01: Handle forward "/" to "index.html"
This is an automated email from the ASF dual-hosted git repository.
hanahmily pushed a commit to branch webapp/proxy
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git
commit 62f46eddc48671de2cdf7ec9ca3b3cbbe81e9d98
Author: gaohongtao <ha...@gmail.com>
AuthorDate: Sun Oct 28 17:26:29 2018 +0800
Handle forward "/" to "index.html"
---
.../org/apache/skywalking/apm/webapp/proxy/MvcConfig.java | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/proxy/MvcConfig.java b/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/proxy/MvcConfig.java
index 81c40ba..a3a7729 100644
--- a/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/proxy/MvcConfig.java
+++ b/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/proxy/MvcConfig.java
@@ -18,12 +18,14 @@
package org.apache.skywalking.apm.webapp.proxy;
+import com.google.common.base.Strings;
import java.io.IOException;
import java.util.Arrays;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.resource.PathResourceResolver;
@@ -33,22 +35,22 @@ import org.springframework.web.servlet.resource.PathResourceResolver;
* @author gaohongtao
*/
@Configuration
-@EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter {
+
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
registry
- .addResourceHandler("/**")
- .addResourceLocations("classpath:/public/")
+ .addResourceHandler("/img/node/**")
+ .addResourceLocations("classpath:/public/img/node/")
.setCachePeriod(3600)
.resourceChain(true)
.addResolver(new PathResourceResolver() {
@Override protected Resource getResource(String resourcePath, Resource location) throws IOException {
Resource raw = super.getResource(resourcePath, location);
- if (raw != null || !resourcePath.startsWith("img/node")) {
+ if (raw != null) {
return raw;
}
- Resource resource = location.createRelative("img/node/UNDEFINED.png");
+ Resource resource = location.createRelative("UNDEFINED.png");
if (!resource.exists() || !resource.isReadable()) {
return null;
}