Class SpringUtil

java.lang.Object
net.mingsoft.basic.util.SpringUtil
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

@Component public class SpringUtil extends Object implements org.springframework.context.ApplicationContextAware
Author:
铭软开发团队
  • Constructor Details

    • SpringUtil

      public SpringUtil()
  • Method Details

    • getRequest

      public static jakarta.servlet.http.HttpServletRequest getRequest()
      获取当前请求对象
      Returns:
    • setRequest

      public static void setRequest(jakarta.servlet.http.HttpServletRequest request)
      设置当前请求对象
    • getBean

      @Deprecated public static Object getBean(jakarta.servlet.ServletContext sc, String beanName)
      Deprecated.
      通过spring的webapplicationcontext上下文对象读取bean对象
      Parameters:
      sc - 上下文servletConext对象
      beanName - 要读取的bean的名称
      Returns:
      返回获取到的对象。获取不到返回null
    • getBean

      public static Object getBean(String beanName)
      通过spring的webapplicationcontext上下文对象读取bean对象
      Parameters:
      beanName - 要读取的bean的名称
      Returns:
      返回获取到的对象。获取不到返回null
    • getBean

      public static <T> T getBean(Class<T> cls)
      通过spring的webapplicationcontext上下文对象读取bean对象
      Parameters:
      cls - 要读取的类名称
      Returns:
      返回获取到的对象。获取不到返回null
    • getProperty

      public static String getProperty(String key)
      读取配置文件中的配置
      Parameters:
      key - 配置文件中对应的key
      Returns:
      对应key配置的值
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • getApplicationContext

      public static org.springframework.context.ApplicationContext getApplicationContext()