这个功能主要是针对在帖子里进行回帖的操作.其实发帖部分功能也可以复用这个功能,先从servlet 开始吧 ActionPost.java,顺便插一句,这里用到了文件上传,我用的上传包是jspsmartupload,可笑的是对中文编码格式支持很不友好,最终找到一个修改过的包,支持GBK编码,将就着用吧,也懒得去改上传的源代码了.
package com.axbbs.bo;    

import java.io.IOException;    
import java.io.PrintWriter;    
import java.text.SimpleDateFormat;    
import java.util.ArrayList;    
import java.util.Calendar;    

import javax.servlet.ServletException;    
import javax.servlet.http.HttpServlet;    
import javax.servlet.http.HttpServletRequest;    
import javax.servlet.http.HttpServletResponse;    
import javax.servlet.http.HttpSession;    
import javax.servlet.jsp.JspFactory;    

import com.axbbs.Dao.WidzPostDAO;    
import com.axbbs.po.PostPo;    
import com.axbbs.po.WidzPostInfo;    
import com.jspsmart.upload.File;    
import com.jspsmart.upload.SmartUpload;    

/**    
* @程序编写 阿汐    
* @版本 1.0    
* @说明 仿wc的jsp版本小论坛    
* @本模块是用于获取帖子提交信息的Servlet类    
* @并且功能并不需要太多,因此本版本没有采用传统意义上的MVC开发模式,而是针对    
* @vo,bo类进行了精简,用po类来共用vo类,用servlet类来共用bo类,很奇怪的开发模式    
* @我都开始佩服起自己来了 050    
* @日期 2008.09.01    
*    
*/
    

public class ActionPost extends HttpServlet {    
     //帖子id    
     int postId;    
     //回帖人    
    String postUserName;    
     //文本内容?    
    String postContent = new String();    

     //引用图片地址    
    String postImgPath = "";    
        
     //包子数字    
    String postImportImgNum="";    
        
     //包子路径    
    String postImportImg="";    
        
     //匿名    
    String postNameHide;    
     /**    
        * Constructor of the object.    
        */
    
     public ActionPost() {    
         super();    
    }    

     /**    
        * Destruction of the servlet.
    
        */
    
     public void destroy() {    
         super.destroy();        

    }    

     /**    
        * The doGet method of the servlet.
    
        *        
        * This method is called when a form has its tag value method equals to get.    
        *        
        * @param request    
        *                                                the request send by the client to the server    
        * @param response    
        *                                                the response send by the server to the client    
        * @throws ServletException    
        *                                                 if an error occurred    
        * @throws IOException    
        *                                                 if an error occurred    
        */
    
     public void doGet(HttpServletRequest request, HttpServletResponse response)    
             throws ServletException, IOException {    
        doPost(request, response);    

    }    

     /**    
        * The doPost method of the servlet.
    
        *        
        * This method is called when a form has its tag value method equals to    
        * post.    
        *        
        * @param request    
        *                                                the request send by the client to the server    
        * @param response    
        *                                                the response send by the server to the client    
        * @throws ServletException    
        *                                                 if an error occurred    
        * @throws IOException    
        *                                                 if an error occurred    
        */
    
     public void doPost(HttpServletRequest request, HttpServletResponse response)    
             throws ServletException, IOException {    

        response.setContentType( "text/html");    
        request.setCharacterEncoding( "GBK");    
        PrintWriter out = response.getWriter();    
         //创建上传对象    
        SmartUpload su = new SmartUpload();    
         //创建回帖对象    
        WidzPostInfo gwpi = new WidzPostInfo();    
         //创建session以期望得到帖子ID号和用户ID信息    
        HttpSession         session         =         request.getSession( true);                
        ArrayList arrayList =(ArrayList)session.getAttribute( "viewList");    
        postId = ((PostPo) arrayList.get(0)).getPostId();    
         //postUserName= ((PostPo) arrayList.get(0)).getPostUserName();    
         try {    
            JspFactory _jspxFactory = JspFactory.getDefaultFactory();    
            javax.servlet.jsp.PageContext pageContext = _jspxFactory    
                    .getPageContext( this, request, response, null, true, 8192,    
                             true);    
             //初始化    
            su.initialize(pageContext);    
             //200k    
            su.setMaxFileSize(200000);    
             //200k    
            su.setTotalMaxFileSize(200000);    
             //允许上传文件    
            su.setAllowedFilesList( "jpg,gif");    
                
             //jsp,htm,html等不允许上传    
            su.setDeniedFilesList( "exe,bat,jsp,htm,html,,");    
            su.upload();    
             //得到文本域信息    
            postContent=(su.getRequest().getParameter( "txtContent"));    
                
            postImgPath=su.getRequest().getParameter( "txtInterfixImg");    
             //包子连接    
            postImportImgNum=su.getRequest().getParameter( "face1")+su.getRequest().getParameter( "face2")+su.getRequest().getParameter( "face3");    
            postImportImg= "/face/"+postImportImgNum+ ".gif";    
             //是否匿名    
            postNameHide=su.getRequest().getParameter( "anonymous");    
                
            postUserName= "alan";    
             //封装帖子对象    

            gwpi.setRefid(postId);    
            gwpi.setPostReContent(postContent);    
            gwpi.setPostReUserName(postUserName);    
            gwpi.setPostReTime( "2008-09-05 15:34:01");    
            gwpi.setPostReImgPath( "http://www.9ijz.com/entries_photo/photo2008032013110029.jpg");    
            gwpi.setPostReFace(postImportImg);    
            gwpi.setPostReFlag(0);    
            gwpi.setPostReIsHide("0");    

            //上传文件结束    
            WidzPostDAO wpd = new WidzPostDAO();    
            String errcode =wpd.addRePost(gwpi);    
            out.println(errcode);    
            //out.println(postContent);    
                
            /*上传文件开始*/    
            File myf = su.getFiles().getFile(0);    

            if (myf.isMissing()) {    
                //out.print("没有选择上传文件");    
            }    
            else {    
                String ext = myf.getFileExt();    
                    
                int file_size = myf.getSize();    
                    
                String saveurl = "";    

                Calendar cal = Calendar.getInstance();    

                String filename = String.valueOf(cal.getTimeInMillis());    

                saveurl = request.getRealPath("/upload");    

                saveurl +="/"+ filename + "." + ext;    

                myf.saveAs(saveurl, su.SAVE_PHYSICAL);    
            }    
            
        }    

        catch (Exception e) {    
            out.print("上传文件错误");    
        }    

    }    

    public void upLoadFile() {    

    }    

    /**    
        * Initialization of the servlet.
    
        *        
        * @throws ServletException    
        *                                                 if an error occure    
        */
    
    public void init() throws ServletException {    
        // Put your code here    
    }    

}    
 
 
OK,这是一个关于回帖的PO类,没什么说的,就是将相关的属性批量get,set方法就是了
 
package com.axbbs.po;

public class WidzPostInfo {
   //id
   private int id;
   //引用帖子id
   private int refid;
   //回帖人
   private String postReUserName;
   //回帖内容
   private String postReContent;
   //回帖时间
   private String postReTime;
   //回帖引用图片
   private String postReImgPath;
   //回帖包子
   private String postReFace;
   //是否匿名
   private String postReIsHide;
   //举旗
   private int postReFlag;
    
   public int getId() {
     return id;
  }
   public void setId( int id) {
     this.id = id;
  }
   public int getRefid() {
     return refid;
  }
   public void setRefid( int refid) {
     this.refid = refid;
  }
   public String getPostReUserName() {
     return postReUserName;
  }
   public void setPostReUserName(String postReUserName) {
     this.postReUserName = postReUserName;
  }
   public String getPostReContent() {
     return postReContent;
  }
   public void setPostReContent(String postReContent) {
     this.postReContent = postReContent;
  }
   public String getPostReTime() {
     return postReTime;
  }
   public void setPostReTime(String postReTime) {
     this.postReTime = postReTime;
  }
   public String getPostReImgPath() {
     return postReImgPath;
  }
   public void setPostReImgPath(String postReImgPath) {
     this.postReImgPath = postReImgPath;
  }
   public String getPostReFace() {
     return postReFace;
  }
   public void setPostReFace(String postReFace) {
     this.postReFace = postReFace;
  }
   public String getPostReIsHide() {
     return postReIsHide;
  }
   public void setPostReIsHide(String postReIsHide) {
     this.postReIsHide = postReIsHide;
  }
   public int getPostReFlag() {
     return postReFlag;
  }
   public void setPostReFlag( int postReFlag) {
     this.postReFlag = postReFlag;
  }
}