⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wileyplugin.java

📁 为struts 的示例程序
💻 JAVA
字号:
package ch04;import java.util.Properties;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import javax.servlet.ServletException;import javax.servlet.ServletContext;import org.apache.struts.action.PlugIn;import org.apache.struts.config.ModuleConfig;import org.apache.struts.action.ActionServlet;public class WileyPlugin implements PlugIn {  public static final String PROPERTIES = "PROPERTIES";  public WileyPlugin() {  }  public void init(ActionServlet servlet,    ModuleConfig applicationConfig)    throws javax.servlet.ServletException {    System.err.println("---->The Plugin is starting<----");    Properties properties = new Properties();    try {      File file =        new File("./web/WEB-INF/props.txt");      FileInputStream fis =        new FileInputStream(file);      properties.load(fis);      ServletContext context = servlet.getServletContext();      context.setAttribute(PROPERTIES, properties);      Properties rProperties = (Properties)context.getAttribute(PROPERTIES);      System.err.println("---->Prop: LDAP " + rProperties.getProperty("LDAP"));    }    catch (FileNotFoundException fnfe) {      System.err.println(fnfe.getMessage());      throw new ServletException(fnfe.getMessage());    }    catch (IOException ioe) {      throw new ServletException(ioe.getMessage());    }  }  public void destroy() {    // We don't have anything to clean up, so    // just log the fact that the Plugin is shutting down    System.err.println("---->The Plugin is stopping<----");  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -