|
|
@ -1,27 +1,25 @@
|
|
|
|
package xyz.wbsite.framework.freemarker;
|
|
|
|
package xyz.wbsite.framework.freemarker;
|
|
|
|
|
|
|
|
|
|
|
|
import xyz.wbsite.framework.utils.LogUtil;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowire;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.web.context.ContextLoader;
|
|
|
|
|
|
|
|
import org.springframework.web.context.WebApplicationContext;
|
|
|
|
|
|
|
|
import org.springframework.web.context.support.WebApplicationContextUtils;
|
|
|
|
|
|
|
|
import org.springframework.web.servlet.DispatcherServlet;
|
|
|
|
import org.springframework.web.servlet.DispatcherServlet;
|
|
|
|
import org.springframework.web.servlet.LocaleResolver;
|
|
|
|
import org.springframework.web.servlet.LocaleResolver;
|
|
|
|
import org.springframework.web.servlet.View;
|
|
|
|
import org.springframework.web.servlet.View;
|
|
|
|
import org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator;
|
|
|
|
import org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator;
|
|
|
|
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
|
|
|
|
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
|
|
|
|
|
|
|
|
import xyz.wbsite.framework.utils.LocalData;
|
|
|
|
|
|
|
|
import xyz.wbsite.framework.utils.LogUtil;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
import javax.servlet.ServletContext;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.File;
|
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* FreemarkerViewName解析器
|
|
|
|
* FreemarkerViewName解析器
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -63,7 +61,7 @@ public class ViewNameTranslator extends DefaultRequestToViewNameTranslator {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Locale locale = localeResolver.resolveLocale(request);
|
|
|
|
Locale locale = localeResolver.resolveLocale(request);
|
|
|
|
|
|
|
|
|
|
|
|
{//查询View
|
|
|
|
{//查询screen
|
|
|
|
String[] split = servletPath.split("/");
|
|
|
|
String[] split = servletPath.split("/");
|
|
|
|
StringBuilder sb = new StringBuilder("");
|
|
|
|
StringBuilder sb = new StringBuilder("");
|
|
|
|
sb.append("screen");
|
|
|
|
sb.append("screen");
|
|
|
@ -75,7 +73,9 @@ public class ViewNameTranslator extends DefaultRequestToViewNameTranslator {
|
|
|
|
View view = viewResolver.resolveViewName(viewName, locale);
|
|
|
|
View view = viewResolver.resolveViewName(viewName, locale);
|
|
|
|
if (view == null) {
|
|
|
|
if (view == null) {
|
|
|
|
LogUtil.e("can not find screen.");
|
|
|
|
LogUtil.e("can not find screen.");
|
|
|
|
return "404";
|
|
|
|
HttpServletResponse response = LocalData.getResponse();
|
|
|
|
|
|
|
|
response.setStatus(HttpStatus.NOT_FOUND.value());
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|