全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第二题 Input.java public class Input extends HttpServlet private static final long serialVersionUID = 1L; public Connection conn; public PreparedStatement ps; public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException request.setCharacterEncoding(“UTF-8“); response.setCharacterEncoding(“gbk“); String title = request.getParameter(“title“); String authorname = request.getParameter(“authorname“); String context = request.getParameter(“context“); String keyword =request.getParameterValues(“keyword“); String local = request.getParameter(“local“); int row = 0; tryClass.forName(“com.mysql.jdbc.Driver“); String uri = “jdbc:mysql:/localhost:3306/test“; String username = “root“; String password = “123“; conn = DriverManager.getConnection(uri,username,password); String sql = “insert into news(title,authorname,context,keyword,local)values(?,?,?,?,?); ps = conn.prepareStatement(sql); ps.setString(1, title); ps.setString(2, authorname); ps.setString(3, context); String str = “; for (int i=0;i=1) response.sendRedirect(“Success.jsp“);else response.sendRedirect(“input.jsp“); catch (Exception e) public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException this.doGet(request, response); 实体类实体类 news 配置文件配置文件 public class News private String title; private String authorname ; private String context ; private String keyword; private String local; public String getTitle() return title; public void setTitle(String title) this.title = title; 。 InputAction.java private static final long serialVersionUID = 1L; public Connection conn; public PreparedStatement ps; private News news; public Connection getConnection() try Class.forName(“com.mysql.jdbc.Driver“); String uri = “jdbc:mysql:/localhost:3306/test“; String username = “root“; String password = “123“; conn = DriverManager.getConnection(uri,username,password); catch (Exception e) e.printStackTrace(); return conn; protected int addNews(News news) String sql = “insert into news(title,authorname,context,keyword,local)values(?,?,?,?,?)“; try ps = new InputAction().getConnection().prepareStatement(sql); ps.setString(1, news.getTitle(); ps.setString(2, news.getAuthorname(); ps.setString(3, news.getContext(); String str = “; for (int i=0;i=1) return SUCCESS; else return ERROR; public News ge
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 幼教课程资源开发路径
- 四年级古诗教学课件及课堂练习设计
- 湘教版地理七年级教学设计大全
- 现代污水处理技术应用项目方案
- 现代企业财务预算管理体系建设
- 小学英语名词所有格教学资源包
- 企业前台工作汇报模板与撰写指南
- 机械焊接工艺总结报告范例
- 办公场所节能环保行为指南
- 高一年级班主任工作会议纪要范例
- 必修四《哲学与文化》-高考政治必背知识归纳梳理总结(统编版)
- 2025年中移铁通有限公司甘肃分公司社会招聘考试参考题库及答案解析
- 小老鼠的探险日记课件
- 全国建筑电工安全培训课件
- 2025年国企综合笔试试题及答案
- 第4章 免疫调节(大单元教学设计)高二生物同步备课系列(人教版2019选择性必修1)
- 幼儿园大班数学《找规律》课件
- 饲料中牛、绵羊和山羊源性成分的定性检测 实时荧光PCR法-编制说明
- 长周期物料管理办法
- 托管班的转让合同协议书
- 快递承包合同解除协议书
评论
0/150
提交评论