六月婷婷综合激情-六月婷婷综合-六月婷婷在线观看-六月婷婷在线-亚洲黄色在线网站-亚洲黄色在线观看网站

明輝手游網(wǎng)中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

半翻譯半整理的一些struts的東東,很淺顯的,歡迎指正(二)

[摘要]3.Struts Plugins:Plugin從Struts1.1開始介紹,它定義了一個org.apache.struts.action.Plugin接口,它主要用來分配資源(allocating ...
3.Struts Plugins:
Plugin從Struts1.1開始介紹,它定義了一個org.apache.struts.action.Plugin接口,它主要用來分配資源(allocating resources)或者建立數(shù)據(jù)庫的連結或者JNDI資源。這個接口提供了兩個必須實現(xiàn)的方法:init()和destroy()。如果運用了Plugin技術,那么在容器啟動的時候,會調用Plugin的init()方法。所以將應用系統(tǒng)的初始化信息寫在這里。當容器停止Struts應用系統(tǒng)的時候,會調用destroy()方法,destroy()方法主要是用來收回在init()方法中分配的資源信息。
◆擴展Plugin類
 ① 創(chuàng)建一個實現(xiàn)Plugin接口的類
 ② 添加一個空的構造器
 ③ 實現(xiàn)init()及destroy()兩個方法
 ④ 在struts-config.xml文件中對<plug-in />元素的配置
創(chuàng)建Plugin必須繼承org.apache.struts.action.Plugin接口。并且實現(xiàn)init()及destroy()方法。例子:
package wiley;

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 config)
throws javax.servlet.ServletException {
System.err.println("....>The Plugin is starting<....");
Properties properties = new Properties();
String path = "C:\\ApplicationResources"+
".properties";
try {
// Build a file object referening the properties file
// to be loaded
File file = new File(path);
// Create an input stream
FileInputStream fis = new FileInputStream(file);
// load the properties
properties.load(fis);
// Get a reference to the ServletContext
ServletContext context = servlet.getServletContext();
// Add the loaded properties to the ServletContext
// for retrieval throughout the rest of the Application
context.setAttribute(PROPERTIES, properties);
}
catch (FileNotFoundException fnfe) {
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<....");
}
}
◆配置Plugin:
在struts-config.xml文件中配置<plug-in>元素。如下:
<plug-in className=”wiley.WileyPlugin” />
<plug-in />的詳細配置信息見”struts-config.xml配置文件講解”。



主站蜘蛛池模板: 四虎黄色网址 | 手机在线日韩高清理论片 | 人人插97| 欧美性猛交xxxx乱大交 | 全部免费毛片免费播放 | 日本高清不卡免费 | 亚洲韩国日本欧美一区二区三区 | 亚洲va欧美va天堂v国产综合 | 在线免费观看亚洲视频 | 在线国产你懂的 | 色橹橹欧美在线观看视频高清 | 日日干狠狠 | 性刺激性色爽爱小说 | 特黄色片 | 欧美在线一二三 | 亚洲三级免费 | 亚洲黄网在线 | 日本抠逼视频 | 天天爽夜夜爽天天做夜夜做 | 天天综合色天天综合 | 日韩操片 | 色456| 色噜噜视频影院 | 亚洲成人在线网站 | 亚洲 欧美 91 | 亚洲精品在线观看视频 | 青娱乐在线视频播放 | 五月婷婷久久综合 | 日韩国产有码在线观看视频 | 在线看国产人成www免费看下载 | 亚洲一区二区三区精品影院 | 亚洲视频在线观看免费视频 | 思思久久99热免费精品6 | 日本特黄a级高清免费酷网 日本特黄aaaaaaa大片 | 欧洲一级视频 | 午夜在线精品不卡国产 | 午夜人屠h精品全集 | 天天拍夜夜添久久精品免费 | 日本激情视频网站 | 午夜资源 | 欧美在线视频第一页 |