?? writefeedbackaction.java
字號:
package cn.com.blogonline;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class WriteFeedbackAction extends HttpServlet {
public void init(ServletConfig config) throws ServletException {
}
/*
* 處理<GET> 請求方法.
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//設置接收信息的字符集
request.setCharacterEncoding("UTF-8");
//接收瀏覽器端提交的信息
String uname = request.getParameter("uname");
String content = request.getParameter("content");
HttpSession session = request.getSession(true);
Article article = (Article)session.getAttribute(Constants.CUR_ARTICLE_KEY);
/*
* 保存至數據庫
*/
DbOperate db=new DbOperate();
FeedBack feedBack=new FeedBack();
feedBack.setUname(uname);
feedBack.setContent(content);
SimpleDateFormat df = new SimpleDateFormat("MMddhhmmss");
df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
feedBack.setPubtime( df.format(new Date()));
feedBack.setArticleid(article.getId());
db.save(feedBack);
response.sendRedirect("showFeedback?articleid="+article.getId() + "&pageid=0");
}
protected void doPost(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException {
// TODO 自動生成方法存根
this.doGet(arg0,arg1);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -