master
wangbing 5 years ago
parent 4641ab8c4f
commit 0b9f6acfaa

@ -145,7 +145,7 @@ public class GlobalController implements ErrorController {
String servletPath = request.getServletPath();// /**/*.htm String servletPath = request.getServletPath();// /**/*.htm
String layout = "/layout/default"; String layout = "/layout/default";
String action = "";// **/* String action = LocalData.getAction();// **/*
Pattern compile = Pattern.compile("^/(.+)\\.htm"); Pattern compile = Pattern.compile("^/(.+)\\.htm");
Matcher matcher = compile.matcher(servletPath); Matcher matcher = compile.matcher(servletPath);
@ -256,7 +256,7 @@ public class GlobalController implements ErrorController {
BaseResponse baseResponse = null; BaseResponse baseResponse = null;
try { try {
Object ajax = LocalData.getApplicationContext().getBean(ActionConfig.AJAX_PREFIX + "." + module + "." + target); Object ajax = LocalData.getApplicationContext().getBean(ActionConfig.AJAX_PREFIX + module + "." + target);
Class ajaxClass = ajax.getClass(); Class ajaxClass = ajax.getClass();
Method methodC = ajaxClass.getMethod(method, String.class); Method methodC = ajaxClass.getMethod(method, String.class);

@ -28,16 +28,17 @@ import java.io.IOException;
*/ */
@Configuration @Configuration
public class ActionConfig implements BeanDefinitionRegistryPostProcessor { public class ActionConfig implements BeanDefinitionRegistryPostProcessor {
public static final String SCREEN_PREFIX = "screen";
public static final String CONTROL_PREFIX = "control"; public static String SCREEN_PREFIX = "/screen/";
public static final String AJAX_PREFIX = "ajax"; public static String CONTROL_PREFIX = "/control/";
public static String AJAX_PREFIX = "/ajax/";
@Override @Override
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry beanDefinitionRegistry) throws BeansException { public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry beanDefinitionRegistry) throws BeansException {
String aPackage = this.getClass().getPackage().getName(); String aPackage = this.getClass().getPackage().getName();
int i = registryScreen("${basePackage}.action.screen", beanDefinitionRegistry); int i = registryScreen("${basePackage}.action.screen.", beanDefinitionRegistry);
int i1 = registryControl("${basePackage}.action.control", beanDefinitionRegistry); int i1 = registryControl("${basePackage}.action.control.", beanDefinitionRegistry);
int i2 = registryAjax("${basePackage}.action.ajax", beanDefinitionRegistry); int i2 = registryAjax("${basePackage}.action.ajax.", beanDefinitionRegistry);
System.out.println(); System.out.println();
} }

@ -2,6 +2,9 @@ package ${basePackage}.config;
import ${basePackage}.frame.auth.LocalData; import ${basePackage}.frame.auth.LocalData;
import ${basePackage}.frame.base.Control; import ${basePackage}.frame.base.Control;
import ${basePackage}.frame.utils.UrlUtil;
import static ${basePackage}.config.ActionConfig.CONTROL_PREFIX;
import static ${basePackage}.config.ActionConfig.SCREEN_PREFIX;
import freemarker.template.SimpleScalar; import freemarker.template.SimpleScalar;
import freemarker.template.TemplateMethodModelEx; import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModelException; import freemarker.template.TemplateModelException;
@ -32,8 +35,7 @@ public class FreeMarkerConfig {
private freemarker.template.Configuration configuration; private freemarker.template.Configuration configuration;
@Value("${r'${server.servlet.context-path}'}") @Value("${r'${server.servlet.context-path}'}")
private String context; private String context;
private String screenPrefix = "/screen/";
private String controlPrefix = "/control/";
private String suffix = ".ftl"; private String suffix = ".ftl";
@PostConstruct @PostConstruct
@ -42,6 +44,7 @@ public class FreeMarkerConfig {
configuration.setSharedVariable("context", context); configuration.setSharedVariable("context", context);
configuration.setSharedVariable("screenHolder", new ScreenHolder()); configuration.setSharedVariable("screenHolder", new ScreenHolder());
configuration.setSharedVariable("controlHolder", new ControlHolder()); configuration.setSharedVariable("controlHolder", new ControlHolder());
configuration.setSharedVariable("UrlUtil", new UrlUtil());
} }
private class ScreenHolder implements TemplateMethodModelEx { private class ScreenHolder implements TemplateMethodModelEx {
@ -72,7 +75,7 @@ public class FreeMarkerConfig {
if (view == null) { if (view == null) {
return ""; return "";
} else { } else {
return screenPrefix + servletPath + suffix; return SCREEN_PREFIX + servletPath + suffix;
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -97,7 +100,7 @@ public class FreeMarkerConfig {
// 查找是否存在对应控制面板执行器 // 查找是否存在对应控制面板执行器
Control controlExec = null; Control controlExec = null;
try { try {
controlExec = LocalData.getApplicationContext().getBean(ActionConfig.CONTROL_PREFIX + "." + control, Control.class); controlExec = LocalData.getApplicationContext().getBean(CONTROL_PREFIX + control, Control.class);
HttpServletRequest request = LocalData.getRequest(); HttpServletRequest request = LocalData.getRequest();
HttpServletResponse response = LocalData.getResponse(); HttpServletResponse response = LocalData.getResponse();
@ -113,7 +116,7 @@ public class FreeMarkerConfig {
} }
control = control.replaceAll("/", File.separator); control = control.replaceAll("/", File.separator);
return controlPrefix + control + suffix; return CONTROL_PREFIX + control + suffix;
} }
} }
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.