?? view.java
字號:
/*
* Created on 2004-9-24
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package com.affice;
import oa.sys.*;
import oa.data.*;
import java.util.*;
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
****************************************************
*類名稱: View<br>
*類功能: 查看公告信息<br>
*創建: 白偉明 2004年10月5日<br>
****************************************************
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class View extends HttpServlet{
private int employeeid;//員工id號
private String time;//發布時間
private Statement stmt;
private ResultSet rs;
private String title,content;//公告標題和內容
private RequestDispatcher dispatcher;//請求轉發對象
private int id=0;//公文編號
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
request.setCharacterEncoding("gb2312");
response.setContentType("text/html; charset=gb2312");
Db db=new Db();
Str str=new Str();
Collection ret=new ArrayList();//獲得一個容器類的對象
PrintWriter out=response.getWriter();
try{
stmt=db.getStmtread();
rs=stmt.executeQuery("SELECT * FROM affice");
while(rs.next()){//從數據庫中取值
id=rs.getInt(1);
title=rs.getString(2);
time=rs.getString(3);
employeeid=rs.getInt(4);
content=rs.getString(5);
title=str.outStr(title);
content=str.outStr(content);
//獲得公告信息Bean的對象,并且給Bean的屬性賦值
Affice affice=new Affice();
affice.setId(id);
affice.setTitle(title);
affice.setEmid(employeeid);
affice.setTime(time);
affice.setContent(content);
//將公告信息Bean的對象添加到容器類的對象中
ret.add(affice);
}
request.setAttribute("msg",ret);
}catch(Exception e){
e.printStackTrace();
}finally{
db.close();
dispatcher=request.getRequestDispatcher("view.jsp");
dispatcher.forward(request,response);
}
}
public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException{
doPost(request,response);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -