资源简介
基于SSM新闻发布系统,包含数据库文件以及完整代码,import即可运行,可进行新闻发布查看删除等一系列功能,不一一列举了......
代码片段和文件信息
package com.action;
import java.io.IOException;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.dao.DB;
import com.orm.TAdmin;
public class admin_servlet extends HttpServlet
{
public void service(HttpServletRequest reqHttpServletResponse res)throws ServletException IOException
{
String type=req.getParameter(“type“);
if(type.endsWith(“adminMana“))
{
adminMana(req res);
}
if(type.endsWith(“adminAdd“))
{
adminAdd(req res);
}
if(type.endsWith(“adminDel“))
{
adminDel(req res);
}
}
public void adminMana(HttpServletRequest reqHttpServletResponse res) throws ServletException IOException
{
List adminList=new ArrayList();
String sql=“select * from t_admin“;
object[] params={};
DB mydb=new DB();
try
{
mydb.doPstm(sql params);
ResultSet rs=mydb.getRs();
while(rs.next())
{
TAdmin admin=new TAdmin();
admin.setUserId(rs.getInt(“userId“));
admin.setUserName(rs.getString(“userName“));
admin.setUserPw(rs.getString(“userPw“));
adminList.add(admin);
}
rs.close();
}
catch(Exception e)
{
e.printStackTrace();
}
mydb.closed();
req.setAttribute(“adminList“ adminList);
req.getRequestDispatcher(“admin/admin/adminMana.jsp“).forward(req res);
}
public void adminAdd(HttpServletRequest reqHttpServletResponse res)
{
String userName=req.getParameter(“userName“);
String userPw=req.getParameter(“userPw“);
String sql=“insert into t_admin values(??)“;
object[] params={userNameuserPw};
DB mydb=new DB();
mydb.doPstm(sql params);
mydb.closed();
req.setAttribute(“message“ “操作成功“);
req.setAttribute(“path“ “admin?type=adminMana“);
String targetURL = “/common/success.jsp“;
dispatch(targetURL req res);
}
public void adminDel(HttpServletRequest reqHttpServletResponse res)
{
System.out.println(req.getParameter(“userId“)+“**“);
String sql=“delete from t_admin where userId=“+Integer.parseInt(req.getParameter(“userId“));
object[] params={};
DB mydb=new DB();
mydb.doPstm(sql params);
mydb.closed();
req.setAttribute(“message“ “操作成功“);
req.setAttribute(“path“ “admin?type=adminMana“);
String targetURL = “/common/success.jsp“;
dispatch(targetURL req res);
}
public void dispatch(String targetURIHttpServletRequest requestHttpServletResponse response)
{
RequestDispatcher dispatch = getServletContext().getRequestDispatcher(targetURI);
try
{
dispatch.forward(request response);
return;
}
catch (ServletException e)
{
e.printStackTrace();
}
相关资源
- maven+ajax+json
- SSM框架思维导图全
- eclipse + maven搭建SSM框架
- ssm实验室设备管理系统.zip
- 基于状态空间的模型预测控制ssmpc.z
- SSM商城系统毕业设计.zip
- 基于ssm的家教管理系统
- ssm驾校预约管理系统.zip
- ssm Dubbo分布式系统架构实战入门,良
- 基于SSM的网上订餐系统的设计与实现
- SSM 下 Excel的导入导出
- Spring+SpringMVC+Mybatis框架+easyUI整合(
- SSM校园社团管理系统.zip
- SSM+Easyui实现——企业销售管理系统
- SSM图书信息管理系统
- 后端开发框架已整合ssm脚手架.zip
- 基于SSM的网上购物系统的设计与开发
- 基于ssm的商品显示
- 传智书城项目完整版
-
ba
seProjectSSM.7z - OSSMS.zip
- 基于ssm医院预约挂号系统程序.zip
- 初学Spring+SpringMVC+MyBatis框架适合初学
- ssm easyui 后台权限管理系统
- Reyco郭-Spring4+SpringMVC+Mybatis讲义
- SSM实现用户注册登录以及增加删除修
- 仿知乎ssm demo.zip
- ssm整合shrio框架
- 基于SSM人事管理OA办公系统
- ssm+bootstrap+angularJs案例
评论
共有 条评论