version fix

This commit is contained in:
shimingxy
2020-04-29 10:03:48 +08:00
parent 78354ff4c6
commit 80d8911fd2
11 changed files with 40 additions and 15 deletions

View File

@@ -30,7 +30,7 @@ public class InitApplicationContext extends HttpServlet {
private static final Logger _logger = LoggerFactory.getLogger(InitApplicationContext.class);
private static final long serialVersionUID = -797399138268601444L;
ApplicationContext applicationContext;
Properties properties;
@Override
public String getServletInfo() {
@@ -146,11 +146,11 @@ public class InitApplicationContext extends HttpServlet {
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer =
((PropertySourcesPlaceholderConfigurer) applicationContext
.getBean("propertySourcesPlaceholderConfigurer"));
properties = (Properties) propertySourcesPlaceholderConfigurer
WebContext.properties = (Properties) propertySourcesPlaceholderConfigurer
.getAppliedPropertySources()
.get(PropertySourcesPlaceholderConfigurer.LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME)
.getSource();
Set<Object> keyValue = properties.keySet();
Set<Object> keyValue = WebContext.properties.keySet();
SortedSet<String> keyValueSet = new TreeSet<String>();
// sort key
for (Iterator<Object> it = keyValue.iterator(); it.hasNext();) {
@@ -160,7 +160,7 @@ public class InitApplicationContext extends HttpServlet {
// out
for (Iterator<String> it = keyValueSet.iterator(); it.hasNext();) {
String key = (String) it.next();
_logger.trace(key + " = " + properties.get(key));
_logger.trace(key + " = " + WebContext.properties.get(key));
}
_logger.trace("-----------------------------------------------------------");
}
@@ -195,7 +195,7 @@ public class InitApplicationContext extends HttpServlet {
_logger.info("+ MaxKey ");
_logger.info("+ Single Sign On ( SSO ) ");
_logger.info("+ Version "
+ properties.getProperty("application.formatted-version"));
+ WebContext.properties.getProperty("application.formatted-version"));
_logger.info("+");
_logger.info("+ https://www.maxkey.top/");
_logger.info("+ email:shimingxy@163.com");

View File

@@ -1,6 +1,7 @@
package org.maxkey.web;
import java.util.Locale;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.LogFactory;
@@ -29,6 +30,8 @@ import org.springframework.web.servlet.support.RequestContextUtils;
*/
public final class WebContext {
public static Properties properties;
/**
* set Current login user to session.
*

View File

@@ -4,6 +4,8 @@ import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.maxkey.web.WebContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -34,21 +36,25 @@ public class LocaleTagDirective implements TemplateDirectiveModel {
throws TemplateException, IOException {
WebApplicationContext webApplicationContext =
RequestContextUtils.findWebApplicationContext(request);
String message = "";
if (params.get("code") == null) {
env.getOut().append(RequestContextUtils.getLocale(request).getLanguage());
message = RequestContextUtils.getLocale(request).getLanguage();
} else if (params.get("code").toString().equals("global.application.version")
|| params.get("code").toString().equals("application.version")) {
message = WebContext.properties.getProperty("application.formatted-version");
} else {
_logger.trace("message code " + params.get("code"));
try {
env.getOut().append(
webApplicationContext.getMessage(
message = webApplicationContext.getMessage(
params.get("code").toString(),
null,
RequestContextUtils.getLocale(request)));
RequestContextUtils.getLocale(request));
} catch (Exception e) {
_logger.error("message code " + params.get("code"), e);
}
}
env.getOut().append(message);
}
}