| | |
| | | package com.yeshi.fanli.util;
|
| | |
|
| | | import java.io.FileNotFoundException;
|
| | | import java.io.IOException;
|
| | | import java.util.Properties;
|
| | |
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | public class PropertyUtil {
|
| | | public static Properties getPropertys(String fileName) {
|
| | |
|
| | | ClassLoader classLoader = PropertyUtil.class.getClass().getClassLoader();
|
| | | Properties pe = new Properties();
|
| | | try {
|
| | | pe.load(classLoader.getResourceAsStream(fileName));
|
| | | } catch (FileNotFoundException e) {
|
| | | e.printStackTrace();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return pe;
|
| | | }
|
| | |
|
| | | // 获取属性
|
| | | public static Properties getPropertys(HttpServletRequest request, String fileName) {
|
| | | try {
|
| | | if (request.getSession().getServletContext().getAttribute(StringUtil.getBase64String(fileName)) != null)
|
| | | return (Properties) request.getSession().getServletContext()
|
| | | .getAttribute(StringUtil.getBase64String(fileName));
|
| | | Properties pe = getPropertys(fileName);
|
| | | request.getSession().getServletContext().setAttribute(StringUtil.getBase64String(fileName), pe);
|
| | | return pe;
|
| | | } catch (FileNotFoundException e) {
|
| | | e.printStackTrace();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | }
|
| | | }
|
| | | package com.yeshi.fanli.util; |
| | | |
| | | import java.io.FileNotFoundException; |
| | | import java.io.IOException; |
| | | import java.util.Properties; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | public class PropertyUtil { |
| | | public static Properties getPropertys(String fileName) { |
| | | |
| | | ClassLoader classLoader = PropertyUtil.class.getClass().getClassLoader(); |
| | | Properties pe = new Properties(); |
| | | try { |
| | | pe.load(classLoader.getResourceAsStream(fileName)); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return pe; |
| | | } |
| | | |
| | | // 获取属性 |
| | | public static Properties getPropertys(HttpServletRequest request, String fileName) { |
| | | try { |
| | | if (request.getSession().getServletContext().getAttribute(StringUtil.getBase64String(fileName)) != null) |
| | | return (Properties) request.getSession().getServletContext() |
| | | .getAttribute(StringUtil.getBase64String(fileName)); |
| | | Properties pe = getPropertys(fileName); |
| | | request.getSession().getServletContext().setAttribute(StringUtil.getBase64String(fileName), pe); |
| | | return pe; |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | } |