Typical usage of servlet

 

 

Typical usage of servlet

 

The parameters here are the parameters of the init method

 

 

<servlet>

   <servlet-name>LoadSystemConfigParameter</servlet-name>

   <servlet-class>core.sys.run.LoadSystemConfigParameterServlet</servlet-class>

   <init-param>

     <param-name>filepathname</param-name>

     <param-value>system.xml</param-value>

   </init-param>

<!-- Database data timing import and export configuration-->

   <init-param>

       <param-name>dbioImpFilePath</param-name>   

       <param-value>classpath:dbio/import.xml</param-value>   

   </init-param>

   <init-param>

       <param-name>dbioExpFilePath</param-name>   

       <param-value>classpath:dbio/export.xml</param-value>   

   </init-param>

   <load-on-startup>1</load-on-startup>

  </servlet>

 

 

system.xml, take it from here 

 

 

 

public class LoadSystemConfigParameterServlet

extends HttpServlet

{

private static final long serialVersionUID = 5130241834911695773L;

private static final Log logger = LogFactory.getLog(LoadSystemConfigParameterServlet.class);

public void init(ServletConfig config)

throws ServletException

{

String filePathName = config.getInitParameter("filepathname");

String homePath = config.getServletContext().getRealPath("");

 

 

 

SystemParameter systemParameter = SystemParameter.getInstance();

systemParameter.setSystemHomePath(homePath);

}

}

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326167272&siteId=291194637