LittleRain

          小雨不打傘 打傘雨不小

          用ROME來作:https://rome.dev.java.net/

          ?

          自己的第一個項目IQBoree
          里面要求有提供給客戶Rss訂閱的功能,找了下網上介紹,最后還是在rome的管網找到了解決方案

          解決方案有兩種:
          1,寫一個servlet,生成feed,直接由客戶來訂閱
          2,寫一個java.自動生成feed的xml文件,然后讓客戶通過讀取這個xml文件來達到訂閱Rss的目的

          首先我就來講解下第一種方法:
          1.
          FeedServlet.java

          package com.iqboree.rss.servlet;
          import java.io.IOException;
          import java.sql.Connection;
          import java.sql.DriverManager;
          import java.sql.ResultSet;
          import java.sql.SQLException;
          import java.sql.Statement;
          import java.text.DateFormat;
          import java.text.ParseException;
          import java.text.SimpleDateFormat;
          import java.util.ArrayList;
          import java.util.Iterator;
          import java.util.List;

          import javax.servlet.http.HttpServlet;
          import javax.servlet.http.HttpServletRequest;
          import javax.servlet.http.HttpServletResponse;

          import org.apache.commons.logging.Log;
          import org.apache.commons.logging.LogFactory;

          import com.iqboree.po.Article;
          import com.iqboree.service.impl.ArticleManagerImpl;
          import com.sun.syndication.feed.synd.SyndContent;
          import com.sun.syndication.feed.synd.SyndContentImpl;
          import com.sun.syndication.feed.synd.SyndEntry;
          import com.sun.syndication.feed.synd.SyndEntryImpl;
          import com.sun.syndication.feed.synd.SyndFeed;
          import com.sun.syndication.feed.synd.SyndFeedImpl;
          import com.sun.syndication.io.FeedException;
          import com.sun.syndication.io.SyndFeedOutput;

          /**

          * @author Michael
          *
          */
          public class FeedServlet extends HttpServlet {
          ?
          ?private static final Log log = LogFactory.getLog(FeedServlet.class);?
          ??? private static final String DEFAULT_FEED_TYPE = "default.feed.type";
          ??? private static final String FEED_TYPE = "type";
          ??? private static final String MIME_TYPE = "application/xml; charset=UTF-8";
          ??? private static final String COULD_NOT_GENERATE_FEED_ERROR = "Could not generate feed";

          ??? private static final DateFormat DATE_PARSER = new SimpleDateFormat("yyyy-MM-dd");



          ??? private String _defaultFeedType;
          ???
          ??? List list;

          ??? public void init() {
          ??????? _defaultFeedType = getServletConfig().getInitParameter(DEFAULT_FEED_TYPE);
          ??????? _defaultFeedType = (_defaultFeedType!=null) ? _defaultFeedType : "atom_0.3";
          ?????? log.info("初始化完成");//用來調試,可以看出在tomcat里的輸出信息,自己可以去掉,后面的log.info()?也是同樣的效果.
          ???????DATE_PARSER.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));//這里用來設置時區
          ???
          ??? }

          ??? public void doGet(HttpServletRequest req,HttpServletResponse res) throws IOException {
          ??????? try {
          ??????? ?log.info("doget方法完成");
          ??????????? SyndFeed feed = getFeed(req);

          ??????????? String feedType = req.getParameter(FEED_TYPE);
          ??????????? feedType = (feedType!=null) ? feedType : _defaultFeedType;
          ??????????? feed.setFeedType(feedType);

          ??????????? res.setContentType(MIME_TYPE);
          ??????????? SyndFeedOutput output = new SyndFeedOutput();
          ??????????? output.output(feed,res.getWriter());
          ??????? }
          ??????? catch (FeedException ex) {
          ??????????? String msg = COULD_NOT_GENERATE_FEED_ERROR;
          ??????????? log(msg,ex);
          ??????????? res.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,msg);
          ??????? }
          ??? }

          ??? protected SyndFeed getFeed(HttpServletRequest req) throws IOException,FeedException {
          ??? ?log.info("Synd方法開始");
          ??? ?
          ??????? SyndFeed feed = new SyndFeedImpl();

          ??????? feed.setTitle("Sample Feed (created with ROME)");//channle name ;display as the title
          ??????? feed.setLink("http://rome.dev.java.net");
          ??????? feed.setDescription("This feed has been created using ROME (Java syndication utilities");
          ???????
          ??????? List entries = new ArrayList();
          ??????? SyndEntry entry;
          ??????? SyndContent description;
          ???????
          ??????? List list = new ArrayList();

          ??????//項目是基于spring+webwork+hibernate的,但是在這里不知道讓為這個servlet自動獲得對應的DAO,所以只能用jdbc手動獲取
          ??????? String sql = "";
          ??????? try {
          ??????? ?log.info("開始進行jdbc操作");
          ???Class.forName("com.mysql.jdbc.Driver");
          ???String url="jdbc:mysql://localhost:3306/iqboree";
          ???Connection conn = DriverManager.getConnection(url,"root","ahuango");
          ???if(conn == null)
          ???{
          ????log.info("conn NULL");
          ???}
          ???Statement stmt = conn.createStatement();
          ???if(stmt==null)
          ???{
          ????log.info("NULLNULLNULL");
          ???}
          ???log.info("開始進行sql操作");
          ???sql = "Select id,AddedDate,AddedBy,Title,Abstract,Body,CommentsEnabled,ViewCount," +
          ?????"ReleaseDate,ExpireDate,Approved,Listed,OnlyForMembers,Category_ID from iq_article";
          ???ResultSet rs = stmt.executeQuery(sql);
          ???log.info("begin iterator resultSet");
          ???while(rs.next())
          ???{
          ????log.info("test 1");
          ????Article art = new Article();
          ????art.setId(Long.valueOf(rs.getString(1)));
          ????log.info("test 2");
          ????art.setAddedDate(rs.getDate(2));
          ????log.info("test 3");
          ????art.setAddedBy(rs.getString(3));
          ????log.info("test 4");
          ????art.setTitle(rs.getString(4));
          ????log.info("test 5");
          ????art.setAbstracts(rs.getString(5));
          ????log.info("test 6");
          ????art.setBody(rs.getString(6));
          ????log.info("test 7");
          ????art.setCommentsEnabled(Boolean.valueOf(rs.getBoolean(7)));
          ????log.info("test 8");
          ????art.setViewCount(Integer.valueOf(rs.getString(8)));
          ????log.info("test 9");
          ????art.setReleaseDate(rs.getDate(9));
          ????log.info("test 10");
          ????art.setExpireDate(rs.getDate(10));
          ????log.info("test 11");
          ????art.setApproved(Boolean.valueOf(rs.getBoolean(11)));
          ????log.info("test 12");
          ????art.setListed(Boolean.valueOf(rs.getBoolean(12)));
          ????log.info("test 13");
          ????art.setOnlyForMembers(Boolean.valueOf(rs.getBoolean(13)));
          ????log.info("test 14");
          //????art.getCategory().setId(Long.valueOf(rs.getString(14)));
          ????log.info("test 15");
          ????
          ????list.add(art);
          ???}??
          ???stmt.close();
          ???conn.close();
          ???
          ??} catch (ClassNotFoundException e) {
          ???// TODO Auto-generated catch block
          ???e.printStackTrace();
          ??}catch(Exception e)
          ??{
          ???log.error("sql:"+sql+"?????? "+e.toString());
          ??}

          //數據庫信息獲取完畢,里面的信息大家根據實際需要自己更改.

          ??????? log.info("開始獲取db");
          ??????? //List articles=new ArticleManagerImpl().getCurrentNArticles(2);
          ??????? log.info("開始迭代");
          ??????
          ???????
          ??????? Iterator its = list.iterator();
          ??????? log.info("開始添加feed條目");
          ??????? while(its.hasNext())
          ??????? {
          ??????? ?Article art=(Article)its.next();
          ??????? ?log.info("在while內部");
          ??????? entry = new SyndEntryImpl();
          ??????? entry.setTitle("\""+art.getTitle()+"\"");
          ??????? entry.setLink("Link is:"+art.getId()+"\"");
          ??????? try {
          ??????????? entry.setPublishedDate(DATE_PARSER.parse("2004-06-08"));
          ??????? }
          ??????? catch (ParseException ex) {
          ??????????? // IT CANNOT HAPPEN WITH THIS SAMPLE
          ??????? }
          ??????? description = new SyndContentImpl();
          ??????? description.setType("text/plain");
          ??????? description.setValue("The value is here:"+art.getTitle()); //set the content of this feed
          ??????? entry.setDescription(description);
          ??????? entries.add(entry);
          ??????? }

          ?

          ??????? feed.setEntries(entries);

          ??????? return feed;
          ??? }

          }

          然后在web.xml中配置這個Rss的訂閱地址
          The web.xml:
          <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
          <web-app>
          ??? <display-name>ROME Samples</display-name>

          ??? <servlet>
          ??????? <servlet-name>FeedServlet</servlet-name>
          ??????? <servlet-class>com.sun.syndication.samples.servlet.FeedServlet</servlet-class>
          ??????? <init-param>
          ??????????? <param-name>default.feed.type</param-name>
          ??????????? <param-value>rss_2.0</param-value>
          ??????? </init-param>
          ??? </servlet>

          ??? <servlet-mapping>
          ???????? <servlet-name>FeedServlet</servlet-name>
          ???????? <url-pattern>/feed</url-pattern>
          ervlet-mapping>

          </web-app>


          我的項目名稱為IQBoree,所以這個feed相應的訂閱地址為:http://localhost:8080/IQBoree/feed


          2,自己生成一個xml文件,然后讓客戶來讀取這個xml文件


          生成xml文件:
          if (true) {
          ??????????? try {
          ??????????????? String feedType = "rss_1.0";
          ??????????????? String fileName = "rssTest2.xml";

          ??????????????? DateFormat dateParser = new SimpleDateFormat(DATE_FORMAT);

          ??????????????? SyndFeed feed = new SyndFeedImpl();
          ??????????????? feed.setFeedType(feedType);

          ??????????????? feed.setTitle("Sample Feed (created with Rome)");
          ??????????????? feed.setLink("??????????????? feed.setDescription("This feed has been created using Rome (Java syndication utilities");

          ??????????????? List entries = new ArrayList();
          ??????????????? SyndEntry entry;
          ??????????????? SyndContent description;

          ??????????????? entry = new SyndEntryImpl();
          ??????????????? entry.setTitle("Rome v1.0");
          ??????????????? entry.setLink("
          ??????????????? entry.setPublishedDate(dateParser.parse("2006-11-16"));
          ??????????????? description = new SyndContentImpl();
          ??????????????? description.setType("text/plain");
          ??????????????? description.setValue("Initial release of Rome");
          ??????????????? entry.setDescription(description);
          ??????????????? entries.add(entry);

          //以上九行可以用來添加一條feed,可以更具自己的需要多添加幾個,或者和第一種生成servlet的方法一樣來從數據庫讀取

          ??????????????? feed.setEntries(entries);

          ??????????????? Writer writer = new FileWriter(fileName);
          ??????????????? SyndFeedOutput output = new SyndFeedOutput();
          ??????????????? output.output(feed,writer);
          ??????????????? writer.close();

          ??????????????? System.out.println("The feed has been written to the file ["+fileName+"]");

          ??????????????? ok = true;
          ??????????? }
          ??????????? catch (Exception ex) {
          ??????????????? ex.printStackTrace();
          ??????????????? System.out.println("ERROR: "+ex.getMessage());
          ??????????? }
          ??????? }



          使用rom讀取rssUrl

          把jdom和rom包拷貝到lib目錄下。

          直接在jsp頁面上嵌入如下代碼:
          <%@ page language="java"
          import="java.util.*;
          import java.net.URL;
          import java.io.InputStreamReader;
          import com.sun.syndication.feed.synd.SyndFeed;
          import com.sun.syndication.io.SyndFeedInput;
          import com.sun.syndication.io.XmlReader;
          " pageEncoding="UTF-8"%>

          <%
          ? try {
          ??????????????? URL feedUrl = new URL("
          http://www.aygfsteel.com/crazycy/CommentsRSS.aspx");
          //上面是那個需要讀取的xml文件的存放地址,我這里找的是偶大哥的blog地址.

          ??????????????? SyndFeedInput input = new SyndFeedInput();
          ??????????????? SyndFeed feed = input.build(new XmlReader(feedUrl));

          //??????????????? System.out.println(feed);

          out.println(feed);

          //??????????????? ok = true;
          ??????????? }
          ??????????? catch (Exception ex) {
          ??????????????? ex.printStackTrace();
          ??????????????? System.out.println("ERROR: "+ex.getMessage());
          ??????????? }
          ?
          ? %>

          =============================================================================================
          使用javaBean:
          <%@page contentType="text/html"%>

          <%@page pageEncoding="UTF-8"%>
          <%@ page import="com.sun.syndication.feed.synd.SyndFeed" %>
          <%@ page import="com.sun.syndication.io.SyndFeedInput"%>
          <%@ page import="com.sun.syndication.io.XmlReader"%>

          <%@page import="java.net.*"%>
          <%@page import="java.util.Properties"%>
          <%@ page import="com.sun.syndication.feed.atom.Feed" %>
          <%@ page import="java.util.List" %>

          <html>

          <head>

          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

          <title>Sina News</title>

          </head>

          <body>

          <%

          ??????? System.out.println("Start...");
          ??????? String str ="http://www.aygfsteel.com/LittleRain/category/15573.html/rss";
          ??????? Properties prop = System.getProperties();
          ?????? // prop.put("http.proxyHost","10.10.10.11");??? //這里填寫代理的ip
          ??????? //prop.put("http.proxyPort","8080");

          ??????? boolean ok = false;
          ??????? try {????????

          ??????????? URL feedUrl = new URL(str);

          ??????????? SyndFeedInput input = new SyndFeedInput();

          ??????????? SyndFeed feed = input.build(new XmlReader(feedUrl));
          ?????????? ??? out.println("Author:"+feed.getAuthor()+"<br>");
          ??? ??? ??? out.println("Title:"+feed.getTitle()+"<br>");
          ??? ??? ??? out.println("Description:"+feed.getDescription()+"<br>");
          ??? ??? ???
          ??? ??? ??? java.util.List list=feed.getEntries();
          ??? ??? ??? for (int i=0; i< list.size(); i++) {

          ??? ??? ??? com.sun.syndication.feed.synd.SyndEntry entry = (com.sun.syndication.feed.synd.SyndEntry)list.get(i);
          ??? ??? ??? //out.println(feed.get);
          ??? ??? ???
          ??? ??? ??? out.println(i+1+":");
          ??? ??? ??? out.println("<a href="+entry.getLink()+">"+entry.getTitle()+"</a>");
          ??? ??? ??? out.println(entry.getPublishedDate()+"<br>");
          ?????????? ??? }


          ??????????? ok = true;
          ??????? }
          ??????? catch (Exception ex) {
          ??????????? ex.printStackTrace();
          ??????????? System.out.println("ERROR: "+ex.getMessage());
          ??????? }


          ??????? if (!ok) {
          ??????????? System.out.println();
          ?????????? out.println("FeedReader reads and prints any RSS/Atom feed type.");
          ??????????? out.println("The first parameter must be the URL of the feed to read.");
          ??????????? System.out.println();
          ??????? }
          ??????
          ??? %>

          </body>

          </html>

          posted @ 2006-11-15 14:05 小雨不打傘 閱讀(1632) | 評論 (3)編輯 收藏

          1。遇到莫名錯誤,學會查看%CATALINA_HOME%\logs下的logs日志。

          2。使用log來輸出:
          在需要調試的類中添加:private static final Log log = LogFactory.getLog(FeedServlet.class);

          posted @ 2006-11-13 22:07 小雨不打傘 閱讀(379) | 評論 (0)編輯 收藏
          1.?上傳文件需要的設置

          a)找到web.xml文件的
          <servlet-name>SimpleUploader</servlet-name>
          <init-param>
          ???<param-name>enabled</param-name>
          ???<param-value>false</param-value>//把這里設置為true
          ??</init-param>

          b)
          〈FCK:editor id="infoContent" basePath="/FCK/FCKeditor/"
          ??????????????width="522"
          ??????????????height="300"
          ??????????????skinPath="/FCK/FCKeditor/editor/skins/silver/"
          ??????????????defaultLanguage="zh-cn"
          ??????????????tabSpaces="8"(需要在fckconfig.js終設置FCKConfig.TabSpaces??= 1 ;開啟Tab鍵功能)
          ??????????????imageBrowserURL="/FCK/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector"
          ??????????????linkBrowserURL="/FCK/FCKeditor/editor/filemanager/browser/default/browser.html?Connector=connectors/jsp/connector"
          ??????????????flashBrowserURL="/FCK/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector"
          ??????????????imageUploadURL="/FCK/FCKeditor/editor/filemanager/upload/simpleuploader?Type=Image"
          ??????????????linkUploadURL="/FCK/FCKeditor/editor/filemanager/upload/simpleuploader?Type=File"
          ????????????? flashUploadURL="/FCK/FCKeditor/editor/filemanager/upload/simpleuploader?Type=Flash"〉
          ????????????? 請輸入內容
          ??〈/FCK:editor〉
          posted @ 2006-11-12 22:46 小雨不打傘 閱讀(968) | 評論 (0)編輯 收藏
          大家在JSP的開發過程中,經常出現中文亂碼的問題,可能一至困擾著您,我現在把我在JSP開發中遇到的中文亂碼的問題及解決辦法寫出來供大家參考。

          一、JSP頁面顯示亂碼
          下面的顯示頁面(display.jsp)就出現亂碼:
          <html>
          <head>
          <title>JSP的中文處理</title>
          <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
          </head>

          <body>
          <%
          out.print("JSP的中文處理");
          %>
          </body>
          </html>
          對不同的WEB服務器和不同的JDK版本,處理結果就不一樣。原因:服務器使用的編碼方式不同和瀏覽器對不同的字符顯示結果不同而導致的。解決辦法:在JSP頁面中指定編碼方式(gb2312),即在頁面的第一行加上:<%@ page contentType="text/html; charset=gb2312"%>,就可以消除亂碼了。完整頁面如下:
          <%@ page contentType="text/html; charset=gb2312"%>
          <html>
          <head>
          <title>JSP的中文處理</title>
          <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
          </head>

          <body>
          <%
          out.print("JSP的中文處理");
          %>
          </body>
          </html>

          二、表單提交中文時出現亂碼
          下面是一個提交頁面(submit.jsp),代碼如下:
          <html>
          <head>
          <title>JSP的中文處理</title>
          <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
          </head>

          <body>
          <form name="form1" method="post" action="process.jsp">
          <div align="center">
          <input type="text" name="name">
          <input type="submit" name="Submit" value="Submit">
          </div>
          </form>
          </body>
          </html>
          下面是處理頁面(process.jsp)代碼:
          <%@ page contentType="text/html; charset=gb2312"%>
          <html>
          <head>
          <title>JSP的中文處理</title>
          <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
          </head>

          <body>
          <%=request.getParameter("name")%>
          </body>
          </html>
          如果submit.jsp提交英文字符能正確顯示,如果提交中文時就會出現亂碼。原因:瀏覽器默認使用UTF-8編碼方式來發送請求,而UTF-8和GB2312編碼方式表示字符時不一樣,這樣就出現了不能識別字符。解決辦法:通過request.seCharacterEncoding("gb2312")對請求進行統一編碼,就實現了中文的正常顯示。修改后的process.jsp代碼如下:
          <%@ page contentType="text/html; charset=gb2312"%>
          <%
          request.seCharacterEncoding("gb2312");
          %>
          <html>
          <head>
          <title>JSP的中文處理</title>
          <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
          </head>

          <body>
          <%=request.getParameter("name")%>
          </body>
          </html>

          三、數據庫連接出現亂碼
          只要涉及中文的地方全部是亂碼,解決辦法:在數據庫的數據庫URL中加上useUnicode=true&characterEncoding=GBK就OK了。

          四、數據庫的顯示亂碼
          在mysql4.1.0中,varchar類型,text類型就會出現中文亂碼,對于varchar類型把它設為binary屬性就可以解決中文問題,對于text類型就要用一個編碼轉換類來處理,實現如下:
          public class Convert {
          /** 把ISO-8859-1碼轉換成GB2312
          */
          public static String ISOtoGB(String iso){
          String gb;
          try{
          if(iso.equals("") || iso == null){
          return "";
          }
          else{
          iso = iso.trim();
          gb = new String(iso.getBytes("ISO-8859-1"),"GB2312");
          return gb;
          }
          }
          catch(Exception e){
          System.err.print("編碼轉換錯誤:"+e.getMessage());
          return "";
          }
          }
          }
          把它編譯成class,就可以調用Convert類的靜態方法ISOtoGB()來轉換編碼。
          posted @ 2006-11-12 20:08 小雨不打傘 閱讀(3818) | 評論 (0)編輯 收藏

          1)
          <html>
          ?<body>
          ??<script language="javascript" src="??? </script>
          ?</body>
          </html>

          2)
          http://sourceforge.net/docman/?group_id=116283

          posted @ 2006-11-12 00:27 小雨不打傘 閱讀(278) | 評論 (0)編輯 收藏

          環境:
          ???eclipse3.1.2,myeclipse4.0.2,tomcat5.0.28

          解決方法:
          ???1.將<taglib>標簽放在<jsp-config>標簽內即可;
          ???2.使用DTD進行驗證

          產生問題的原因:
          ???將出問題的web.xml文件與tomcat下其它的文件進行比較發現,區別在于xml文件使用了不同的文檔類型描述
          ???能夠直接添加的web.xml使用是DTD
          ???

          <! DOCTYPE?web-app
          ????PUBLIC?"-//Sun?Microsystems,?Inc.//DTD?Web?Application?2.3//EN"
          ????"http://java.sun.com/dtd/web-app_2_4.dtd"
          >


          ???而我的這個web使用的是XML Schema

          < web-app? xmlns ="http://java.sun.com/xml/ns/j2ee" ?xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance" ?version ="2.4" ?xsi:schemaLocation ="http://java.sun.com/xml/ns/j2ee???http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
          posted @ 2006-11-10 15:27 小雨不打傘 閱讀(701) | 評論 (0)編輯 收藏
          ????????首先下載并解壓最新的FCKeditor到各自的目錄,一個是FCKeditor的核心文件,另一個是針對jsp的文件包
          下載地址:http://www.fckeditor.net/download

          ?????????接下來我們可以開始配置了。
          我是在eclipse下來配置的
          環境:
          jdk:1.4
          eclisp:3.12
          plugin:myeclipse4.0
          FCKeditor :FCKeditor_2.3.2
          FCKeditor.java:FCKeditor-2.3

          1.新建一個webproject,我這里取名為FCK。

          2.把FCKeditor_2.3.2目錄下的FCKeditor目錄拷貝到FCK工程的根目錄,即WebRoot目錄下。

          3.將FCKeditor-2.3\web\WEB-INF目錄下的web.xml中的兩個servlet,servlet-mapping定義復制到工程的web.xml文件中去。

          4.修改web.xml文件

          <servlet-mapping>?
          ????????<servlet-name>Connector</servlet-name>?
          ????????<url-pattern>/editor/filemanager/browser/default/connectors/jsp/connector</url-pattern>?
          ????</servlet-mapping>?

          ????<servlet-mapping>?
          ????????<servlet-name>SimpleUploader</servlet-name>?
          ????????<url-pattern>/editor/filemanager/upload/simpleuploader</url-pattern>??
          ?</servlet-mapping>

            為

          <servlet-mapping>?
          ????????<servlet-name>Connector</servlet-name>?
          ????????<url-pattern>/FCKeditor/editor/filemanager/browser/default/connectors/jsp/connector</url-pattern>?
          ????</servlet-mapping>?

          ????<servlet-mapping>?
          ????????<servlet-name>SimpleUploader</servlet-name>?
          ????????<url-pattern>/FCKeditor/editor/filemanager/upload/simpleuploader</url-pattern>??
          ??</servlet-mapping>

          這里的/FCKeditor/是對應你webroot目錄下的FCKeditor目錄。

          5.拷貝FCKeditor-2.3\web\WEB-INF\lib下的兩個jar包到WebRoot\WEB-INF\lib目錄下
          (在項目的庫中添加FCKeditor-2.3\web\WEB-INF\lib下的兩個jar包? 達不到同樣的效果,一定要拷貝到lib目錄下)

          6.在webroot目錄下新建一個jsp,使用默認的MyJsp.jsp即可。

          7. 文件開頭處加入? :
          <%@ taglib uri="
          8.在jsp中嵌入的代碼:在Jsp中使用
          方法一:(可能會出現:The requested resource (/FCK/editor/fckeditor.html) is not available)
          <c:set var="basepath"><c:url value="/fck/" /></c:set>
          <FCK:editor id="descn" basePath="${basepath}" height="500px">
          <c:out value="${book.descn}" escapeXml="false" default="" />
          </FCK:editor>

          方法二:
          <FCK:editor id="infoContent" basePath="/FCK/FCKeditor/"
          ????????????? width="800"
          ????????????? height="300"?????????????????????????
          ????????????? >
          ????????????? 請輸入內容
          </FCK:editor>

          9.部署好工程,開啟tomcat,打開MyJsp.jsp頁面即可。




          10.三種方法調用FCKeditor
          <%--
          三種方法調用FCKeditor
          1.FCKeditor自定義標簽 (必須加頭文件 <%@ taglib uri="/TestFCKeditor" prefix="FCK" %> )
          2.script腳本語言調用 (必須引用 腳本文件 <script type="text/javascript" src="/TestFCKeditor/FCKeditor/fckeditor.js"></script> )
          3.FCKeditor API 調用 (必須加頭文件 <%@ page language="java" import="com.fredck.FCKeditor.*" %> )
          --%>

          <%--
          <form action="show.jsp" method="post" target="_blank">
          <FCK:editor id="content" basePath="/TestFCKeditor/FCKeditor/"
          width="700"
          height="500"
          skinPath="/TestFCKeditor/FCKeditor/editor/skins/silver/"
          toolbarSet = "Default"
          >
          input
          </FCK:editor>
          <input type="submit" value="Submit">
          </form>
          --%>

          <form action="show.jsp" method="post" target="_blank">
          <table border="0" width="700"><tr><td>
          <textarea id="content" name="content" style="WIDTH: 100%; HEIGHT: 400px">input</textarea>
          <script type="text/javascript">
          var oFCKeditor = new FCKeditor('content') ;
          oFCKeditor.BasePath = "/TestFCKeditor/FCKeditor/" ;
          oFCKeditor.Height = 400;
          oFCKeditor.ToolbarSet = "Default" ;
          oFCKeditor.ReplaceTextarea();
          </script>
          <input type="submit" value="Submit">
          </td></tr></table>
          </form>

          <%--
          <form action="show.jsp" method="post" target="_blank">
          <%
          FCKeditor oFCKeditor ;
          oFCKeditor = new FCKeditor( request, "content" ) ;
          oFCKeditor.setBasePath( "/TestFCKeditor/FCKeditor/" ) ;
          oFCKeditor.setValue( "input" );
          out.println( oFCKeditor.create() ) ;
          %>
          <br>
          <input type="submit" value="Submit">
          </form>
          --%>

          添加文件/TestFCKeditor/show.jsp:
          <%
          String content = request.getParameter("content");
          out.print(content);
          out.println(request.getParameter("title"));
          %>
          <!--表單中的input的name可以等于這里request.getParameter("parameter") 中的parameter參數。可以通過out.println輸出
          <FCK:editor id="content".....>FCK中的id相當于input的name
          -->



          11.FCKeditor編輯器文件上傳配置

          FCKeditor編輯器的配置文件是fckconfig.js,其中有對編輯器各種默認屬性的設置。以下是fckeditor與java集成使用 時上傳文件的設置(需要注意的是編輯器不會自動創建文件上傳的文件夾,需要在項目的根目錄中手動添加),將fckeditor.js文件中以下幾個屬性原 來的值修改為如下設置:

          FCKConfig.LinkBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Connector=connectors/jsp/connector" ;
          FCKConfig.ImageBrowserURL = FCKConfig.BasePath + "filemanager/browser/default/browser.html?Type=Image&Connector=connectors/jsp/connector" ;
          FCKConfig.FlashBrowserURL =FCKConfig.BasePath + "filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/jsp/connector" ;

          FCKConfig.LinkUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=File' ;
          FCKConfig.ImageUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=Image' ;
          FCKConfig.FlashUploadURL = FCKConfig.BasePath + 'filemanager/upload/simpleuploader?Type=Flash' ;

          至此,即可使用FCKeditor的文件上傳功能。

          posted @ 2006-11-10 12:42 小雨不打傘 閱讀(2230) | 評論 (2)編輯 收藏
          jdbc:mysql://hostName:3306/dbName
          posted @ 2006-11-05 10:43 小雨不打傘 閱讀(602) | 評論 (0)編輯 收藏

          1)下載EclipseWork和EasySQL

          download URL :http://sourceforge.net/project/showfiles.php?group_id=98634

          注意:我使用EclipseWork0.9.0和Eclipse3.1.2總是沒辦法安裝成功,可能是EclipseWork0.9.0和其他的兼容問題吧,也可能是rp問題。
          我最終安裝成功的版本:EclipseWork0.8.0Eclipse3.1.2。(EasySQL-1.06和EasySQL-1.1)


          EclipseWork主頁:http://eclipsework.sourceforge.net

          2)通過link方式安裝兩個plugin,嫌麻煩也可以把東西的plugins目錄下的東東直接扔到eclipse的plugins目錄下。

          3)命令行下到eclipse目錄下:用clean方式重啟:
          eclipse -clean。

          4)安裝成功后的圖片:o_EclipseWork.jpg

          5)EclipseWork安裝完成后的配置:
          點擊菜單Window-->Preferences-->EclipseWork,在"wizards.xml"一欄中輸入templates-0.1\wizards.xml,在"Velocity Templates'Folder"一欄中輸入templates-0.1\templates,點確定。

          OK~至此EclipseWork插件的安裝基本完成。

          posted @ 2006-11-02 18:24 小雨不打傘 閱讀(644) | 評論 (0)編輯 收藏
          1.實現多線程的兩種方法
          a) extends Thread類
          b)implemens Runnable 接口

          2.線程的常用方法
          a) interrupt()? 中斷線程。
          b) isAlive()? 測試線程是否處于活動狀態。
          c) join() ? 等待該線程終止。
          d) sleep(long?millis)? 在指定的毫秒數內讓當前正在執行的線程休眠(暫停執行)。
          e) yield()? 暫停當前正在執行的線程對象,并執行其他線程。
          f)public final void wait(long?timeout) throws InterruptedException
          ??? 導致當前的線程等待,直到其他線程調用此對象的notify()方法或notifyAll()方法,或者超過指定的時間量。
          g)public final void notify()? 喚醒在此對象監視器上等待的單個線程。

          3.
          posted @ 2006-10-16 22:12 小雨不打傘 閱讀(177) | 評論 (0)編輯 收藏
          僅列出標題
          共6頁: 上一頁 1 2 3 4 5 6 下一頁 

          公告

          點擊這里給我發消息 QQ:232720563


            MSN:new_haihua@hotmail.com

          導航

          統計

          常用鏈接

          留言簿(2)

          隨筆分類(51)

          最新隨筆

          積分與排名

          最新評論

          閱讀排行榜

          主站蜘蛛池模板: 武安市| 常山县| 新郑市| 英德市| 嘉定区| 定安县| 读书| 绥芬河市| 亚东县| 千阳县| 麟游县| 疏勒县| 安康市| 孟连| 礼泉县| 江津市| 永川市| 普定县| 南安市| 阿拉善右旗| 清镇市| 上杭县| 离岛区| 许昌县| 昌吉市| 渑池县| 谢通门县| 宜章县| 乌鲁木齐市| 陆丰市| 庄浪县| 和龙市| 贵南县| 屯留县| 扬中市| 浮梁县| 新安县| 来凤县| 自贡市| 湛江市| 株洲县|