博客
关于我
新闻发布项目——Servlet类(doNews_readServlet )
阅读量:581 次
发布时间:2019-03-11

本文共 1686 字,大约阅读时间需要 5 分钟。

package bdqn.newsManageServlet.Servlet;import java.io.IOException;import java.io.PrintWriter;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import bdqn.newsManageServlet.Dao.commentDao;import bdqn.newsManageServlet.Dao.Impl.commentDaoImpl;import bdqn.newsManageServlet.entity.comment;public class doNews_readServlet extends HttpServlet {    public void destroy() {        super.destroy();    }    public void doGet(HttpServletRequest request, HttpServletResponse response)            throws ServletException, IOException {        response.setContentType("text/html;charset=utf-8");        PrintWriter out = response.getWriter();        request.setCharacterEncoding("utf-8");        String user = request.getParameter("cauthor");        String ip = request.getParameter("cip");        String connect = request.getParameter("ccontent");        int newsid = Integer.parseInt(request.getParameter("newsid"));        commentDao comdao = new commentDaoImpl();        comment comm = new comment();        comm.setCmmUser(user);        comm.setIp(ip);        comm.setCmmContent(connect);        comm.setNewsID(newsid);        int rel = comdao.addComment(comm);        if (rel > 0) {            request.getRequestDispatcher("/newspages/news_read.jsp?newsid=" + newsid).forward(request, response);        } else {            out.print("");        }    }    public void doPost(HttpServletRequest request, HttpServletResponse response)            throws ServletException, IOException {        doGet(request, response);    }    public void init() throws ServletException {    }}

转载地址:http://clutz.baihongyu.com/

你可能感兴趣的文章
php 将XML对象转化为数组
查看>>
PHP 工具
查看>>
php 常用方法
查看>>
PHP 并发扣款,保证数据一致性(悲观锁和乐观锁)
查看>>
php 延迟静态绑定static关键字
查看>>
php 引用 -
查看>>
Redis入门
查看>>
PHP 截取字符串乱码的解决方案
查看>>
php 接口类与抽象类的实际作用
查看>>
PHP 插入排序 -- 折半查找
查看>>
PHP 支持8种基本的数据类型
查看>>
php 放大镜,放大镜放大图片效果
查看>>
php 数据库 表格数据,php数据库到excel表格-php怎么把数据库数据放到表格里
查看>>
PHP 数据库连接池实现
查看>>
php 数组 区别,PHP中数组的区别
查看>>
PHP 数组怎么添加一个元素
查看>>
PHP 文件上传
查看>>
PHP 文件操作
查看>>
php 文字弹幕效果代码,HTML5文字弹幕效果
查看>>
php 时间日期函数,获取今天开始时间,结束时间
查看>>