基于javaweb+mysql的ssm校园社团门户网站管理系统(前台、后台)(java+jsp+ssm+mysql)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
分为前台和后台
前台校园门户网站信息查看:学生
后台内容管理:管理员、教师、社团(角色不同,权限菜单不同)
前台
后台
技术框架
JavaBean MVC JSP SSM(Spring SpringMVC MyBatis) MySQL jQuery JavaScript CSS…
基于javaweb的SSM校园社团门户网站管理系统(前台、后台)(java+jsp+ssm+mysql)
/**
* 分页查询 返回list json(通过Map)
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findByMap.json", method = RequestMethod.GET)
@ResponseBody
public String findByMapMap(SchoolInfo schoolInfo, Model model, HttpServletRequest request, HttpServletResponse response) {
//通过map查询
Map<String,Object> params = new HashMap<String,Object>();
if(!isEmpty(schoolInfo.getContent())){
params.put("content", schoolInfo.getContent());
}
if(!isEmpty(schoolInfo.getAddTime())){
params.put("addTime", schoolInfo.getAddTime());
}
if(!isEmpty(schoolInfo.getAddUserId())){
params.put("addUserId", schoolInfo.getAddUserId());
}
//分页查询
Pager<SchoolInfo> pagers = schoolInfoService.findByMap(params);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("pagers", pagers);
jsonObject.put("obj", schoolInfo);
return jsonObject.toString();
}
/**
* ajax 添加
* @param
* @return
*/
@RequestMapping(value = "/exAdd.json", method = RequestMethod.POST)
@ResponseBody
public String exAddJson(SchoolInfo schoolInfo, Model model, HttpServletRequest request, HttpServletResponse response) {
schoolInfoService.insert(schoolInfo);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("message", "添加成功");
return jsonObject.toString();
}
/**
* 分页查询 返回list json(通过Map)
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findByMap.json", method = RequestMethod.GET)
@ResponseBody
public String findByMapMap(Action action, Model model, HttpServletRequest request, HttpServletResponse response) {
//通过map查询
Map<String,Object> params = new HashMap<String,Object>();
if(!isEmpty(action.getName())){
params.put("name", action.getName());
}
if(!isEmpty(action.getIsDelete())){
params.put("isDelete", action.getIsDelete());
}
//分页查询
Pager<Action> pagers = actionService.findByMap(params);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("pagers", pagers);
jsonObject.put("obj", action);
return jsonObject.toString();
}
/**
* ajax 添加
* @param
* @return
*/
@RequestMapping(value = "/exAdd.json", method = RequestMethod.POST)
@ResponseBody
public String exAddJson(Action action, Model model, HttpServletRequest request, HttpServletResponse response) {
actionService.insert(action);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("message", "添加成功");
return jsonObject.toString();
}
File file=new File(filePath+"/"+pre + files[i].getOriginalFilename());
if(!file.exists()){
file.createNewFile();
}
files[i].transferTo(file);
} catch (Exception e) {
e.printStackTrace();
System.out.println("上传出错");
}
}
}
return "";
}
// --------------------------------------- 华丽分割线 ------------------------------
}
/**
* @ClassName:
* @Description:
*/
/**
* ajax 添加
* @param
* @return
*/
@RequestMapping(value = "/exAdd.json", method = RequestMethod.POST)
@ResponseBody
public String exAddJson(SchoolInfo schoolInfo, Model model, HttpServletRequest request, HttpServletResponse response) {
schoolInfoService.insert(schoolInfo);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("message", "添加成功");
return jsonObject.toString();
}
/**
* ajax 修改
* @param
* @return
*/
@RequestMapping(value = "/exUpdate.json",method = RequestMethod.POST)
@ResponseBody
public String exUpdateJson(SchoolInfo schoolInfo, Model model, HttpServletRequest request, HttpServletResponse response) {
schoolInfoService.update(schoolInfo);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("message", "修改成功");
return jsonObject.toString();
}
/**
* ajax 删除
* @return
*/
@RequestMapping(value = "/delete.json", produces = "text/html;charset=UTF-8", method = RequestMethod.GET)
@ResponseBody
public String exDeleteJson(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
//真正删除
schoolInfoService.deleteById(id);
//通过参数删除
//Map<String,Object> params = new HashMap<String,Object>();
//params.put("id", id);
//schoolInfoService.deleteBySqId("deleteBySql", params);
//状态删除
/**
* ajax 删除
* @return
*/
@RequestMapping(value = "/delete.json", produces = "text/html;charset=UTF-8", method = RequestMethod.GET)
@ResponseBody
public String exDeleteJson(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
//真正删除
webCountService.deleteById(id);
//通过参数删除
//Map<String,Object> params = new HashMap<String,Object>();
//params.put("id", id);
//webCountService.deleteBySqId("deleteBySql", params);
//状态删除
//WebCount load = webCountService.load(id);
//load.setIsDelete(1);
//webCountService.update(load);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("message", "删除成功");
return jsonObject.toString();
}
/**
* 单文件上传
* @param file
* @param request
* @param model
* @return
*/
@RequestMapping(value = "/saveFile")
public String saveFile(@RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request, Model model) {
System.out.println("开始");
String path = request.getSession().getServletContext().getRealPath("/upload");
String fileName = file.getOriginalFilename();
System.out.println(path);
File targetFile = new File(path, fileName);
if(!targetFile.exists()){
targetFile.mkdirs();
}
//保存
try {
file.transferTo(targetFile);
} catch (Exception e) {
}
/**
* 分页查询 返回list json(通过Map)
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findByMap.json", method = RequestMethod.GET)
@ResponseBody
public String findByMapMap(WebCount webCount, Model model, HttpServletRequest request, HttpServletResponse response) {
//通过map查询
Map<String,Object> params = new HashMap<String,Object>();
if(!isEmpty(webCount.getCountAll())){
params.put("countAll", webCount.getCountAll());
}
//分页查询
Pager<WebCount> pagers = webCountService.findByMap(params);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("pagers", pagers);
jsonObject.put("obj", webCount);
return jsonObject.toString();
}
/**
* ajax 添加
* @param
* @return
*/
@RequestMapping(value = "/exAdd.json", method = RequestMethod.POST)
@ResponseBody
public String exAddJson(WebCount webCount, Model model, HttpServletRequest request, HttpServletResponse response) {
webCountService.insert(webCount);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("message", "添加成功");
return jsonObject.toString();
}
/**
* ajax 修改
* @param
* @return
*/
@RequestMapping(value = "/exUpdate.json",method = RequestMethod.POST)
@ResponseBody
public String exUpdateJson(WebCount webCount, Model model, HttpServletRequest request, HttpServletResponse response) {
webCountService.update(webCount);
JSONObject jsonObject = JsonUtil2.getJsonObject();
* @param
* @return
*/
@RequestMapping(value = "/exUpdate.json",method = RequestMethod.POST)
@ResponseBody
public String exUpdateJson(Action action, Model model, HttpServletRequest request, HttpServletResponse response) {
actionService.update(action);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("message", "修改成功");
return jsonObject.toString();
}
/**
* ajax 删除
* @return
*/
@RequestMapping(value = "/delete.json", produces = "text/html;charset=UTF-8", method = RequestMethod.GET)
@ResponseBody
public String exDeleteJson(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
//真正删除
actionService.deleteById(id);
//通过参数删除
//Map<String,Object> params = new HashMap<String,Object>();
//params.put("id", id);
//actionService.deleteBySqId("deleteBySql", params);
//状态删除
//Action load = actionService.load(id);
//load.setIsDelete(1);
//actionService.update(load);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("message", "删除成功");
return jsonObject.toString();
}
/**
* 单文件上传
* @param file
* @param request
* @param model
* @return
*/
@RequestMapping(value = "/saveFile")
public String saveFile(@RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request, Model model) {
System.out.println("开始");
String path = request.getSession().getServletContext().getRealPath("/upload");
String fileName = file.getOriginalFilename();
System.out.println(path);
File targetFile = new File(path, fileName);
if(!targetFile.exists()){
targetFile.mkdirs();
//SchoolJob load = schoolJobService.load(id);
//load.setIsDelete(1);
//schoolJobService.update(load);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("message", "删除成功");
return jsonObject.toString();
}
/**
* 单文件上传
* @param file
* @param request
* @param model
* @return
*/
@RequestMapping(value = "/saveFile")
public String saveFile(@RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request, Model model) {
System.out.println("开始");
String path = request.getSession().getServletContext().getRealPath("/upload");
String fileName = file.getOriginalFilename();
System.out.println(path);
File targetFile = new File(path, fileName);
if(!targetFile.exists()){
targetFile.mkdirs();
}
//保存
try {
file.transferTo(targetFile);
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
/**
* springMvc多文件上传
* @param files
* @param id
* @return
*/
@RequestMapping(value = "/saveFiles")
public String saveFiles(@RequestParam("file") CommonsMultipartFile[] files,Integer id,HttpServletRequest request){
for(int i = 0;i<files.length;i++){
System.out.println("fileName---------->" + files[i].getOriginalFilename());
if(!files[i].isEmpty()){
int pre = (int) System.currentTimeMillis();
try {
//拿到输出流,同时重命名上传的文件
String filePath = request.getRealPath("/upload");
File f=new File(filePath);
if(!f.exists()){
f.mkdirs();
public String exAdd(RoleAction roleAction, Model model, HttpServletRequest request, HttpServletResponse response) {
roleActionService.insert(roleAction);
return "redirect:/roleAction/findByObj.do";
}
/**
* 跳至修改页面
* @return
*/
@RequestMapping(value = "/update.do")
public String update(Integer id,Model model) {
RoleAction obj = roleActionService.load(id);
model.addAttribute("obj",obj);
return "roleAction/update";
}
/**
* 添加修改
* @return
*/
@RequestMapping(value = "/exUpdate.do")
public String exUpdate(RoleAction roleAction, Model model, HttpServletRequest request, HttpServletResponse response) {
roleActionService.update(roleAction);
return "redirect:/roleAction/findByObj.do";
}
/**
* 删除通过主键
* @return
*/
@RequestMapping(value = "/delete.do")
public String delete(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
//真正删除
roleActionService.deleteById(id);
//通过参数删除
//Map<String,Object> params = new HashMap<String,Object>();
//params.put("id", id);
//roleActionService.deleteBySqId("deleteBySql", params);
//状态删除
//RoleAction load = roleActionService.load(id);
//load.setIsDelete(1);
//roleActionService.update(load);
return "redirect:/roleAction/findByObj.do";
}
// --------------------------------------- 华丽分割线 ------------------------------
/**
* 分页查询 返回list json(通过对象)
*
* @param request
* @param response
e.printStackTrace();
System.out.println("上传出错");
}
}
}
return "";
}
// --------------------------------------- 华丽分割线 ------------------------------
}
/**
* @ClassName:
* @Description:
*/
@Controller
@RequestMapping("/webCount")
public class WebCountController extends BaseController {
/**
* 依赖注入 start dao/service/===
*/
@Autowired
private WebCountService webCountService;
// --------------------------------------- 华丽分割线 ------------------------------
targetFile.mkdirs();
}
//保存
try {
file.transferTo(targetFile);
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
/**
* springMvc多文件上传
* @param files
* @param id
* @return
*/
@RequestMapping(value = "/saveFiles")
public String saveFiles(@RequestParam("file") CommonsMultipartFile[] files,Integer id,HttpServletRequest request){
for(int i = 0;i<files.length;i++){
System.out.println("fileName---------->" + files[i].getOriginalFilename());
if(!files[i].isEmpty()){
int pre = (int) System.currentTimeMillis();
try {
//拿到输出流,同时重命名上传的文件
String filePath = request.getRealPath("/upload");
File f=new File(filePath);
if(!f.exists()){
f.mkdirs();
}
String fileNmae=new Date().getTime() + files[i].getOriginalFilename();
File file=new File(filePath+"/"+pre + files[i].getOriginalFilename());
if(!file.exists()){
file.createNewFile();
}
files[i].transferTo(file);
} catch (Exception e) {
e.printStackTrace();
System.out.println("上传出错");
}
}
}
return "";
}
/**
* 分页查询 返回list对象(通过对象)
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findByObj.do")
public String findByObj(User user, Model model, HttpServletRequest request, HttpServletResponse response) {
//分页查询
Pager<User> pagers = userService.findByEntity(user);
model.addAttribute("pagers", pagers);
//存储查询条件
model.addAttribute("obj", user);
return "user/user";
}
/**
* 分页查询 返回list对象(通过Map)
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findByMap.do")
public String findByMap(User user, Model model, HttpServletRequest request, HttpServletResponse response) {
//通过map查询
Map<String,Object> params = new HashMap<String,Object>();
if(!isEmpty(user.getUserName())){
params.put("userName", user.getUserName());
}
if(!isEmpty(user.getNickName())){
params.put("nickName", user.getNickName());
}
if(!isEmpty(user.getPassWord())){
params.put("passWord", user.getPassWord());
}
if(!isEmpty(user.getCode())){
params.put("code", user.getCode());
}
if(!isEmpty(user.getZy())){
params.put("zy", user.getZy());
}
if(!isEmpty(user.getNj())){
Pager<News> pagers = newsService.findByMap(params);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("pagers", pagers);
jsonObject.put("obj", news);
return jsonObject.toString();
}
/**
* ajax 添加
* @param
* @return
*/
@RequestMapping(value = "/exAdd.json", method = RequestMethod.POST)
@ResponseBody
public String exAddJson(News news, Model model, HttpServletRequest request, HttpServletResponse response) {
newsService.insert(news);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("message", "添加成功");
return jsonObject.toString();
}
/**
* ajax 修改
* @param
* @return
*/
@RequestMapping(value = "/exUpdate.json",method = RequestMethod.POST)
@ResponseBody
public String exUpdateJson(News news, Model model, HttpServletRequest request, HttpServletResponse response) {
newsService.update(news);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("message", "修改成功");
return jsonObject.toString();
}
/**
* ajax 删除
* @return
*/
targetFile.mkdirs();
}
//保存
try {
file.transferTo(targetFile);
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
/**
* springMvc多文件上传
* @param files
* @param id
* @return
*/
@RequestMapping(value = "/saveFiles")
public String saveFiles(@RequestParam("file") CommonsMultipartFile[] files,Integer id,HttpServletRequest request){
for(int i = 0;i<files.length;i++){
System.out.println("fileName---------->" + files[i].getOriginalFilename());
if(!files[i].isEmpty()){
int pre = (int) System.currentTimeMillis();
try {
//拿到输出流,同时重命名上传的文件
String filePath = request.getRealPath("/upload");
File f=new File(filePath);
if(!f.exists()){
f.mkdirs();
}
String fileNmae=new Date().getTime() + files[i].getOriginalFilename();
File file=new File(filePath+"/"+pre + files[i].getOriginalFilename());
if(!file.exists()){
file.createNewFile();
}
files[i].transferTo(file);
} catch (Exception e) {
e.printStackTrace();
System.out.println("上传出错");
}
}
}
return "";
}
// --------------------------------------- 华丽分割线 ------------------------------
//actionService.deleteById(id);
//通过参数删除
//Map<String,Object> params = new HashMap<String,Object>();
//params.put("id", id);
//actionService.deleteBySqId("deleteBySql", params);
//状态删除
Action load = actionService.load(id);
load.setIsDelete(1);
actionService.update(load);
return "redirect:/action/findByObj.do";
}
// --------------------------------------- 华丽分割线 ------------------------------
/**
* 分页查询 返回list json(通过对象)
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findByObj.json", method = RequestMethod.GET)
@ResponseBody
public String findByObjByEntity(Action action, Model model, HttpServletRequest request, HttpServletResponse response) {
//分页查询
Pager<Action> pagers = actionService.findByEntity(action);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("pagers", pagers);
jsonObject.put("obj", action);
return jsonObject.toString();
}
/**
* 分页查询 返回list json(通过Map)
*
* @param request
* @param response
* @return
*/
@RequestMapping(value = "/findByMap.json", method = RequestMethod.GET)
@ResponseBody
public String findByMapMap(Action action, Model model, HttpServletRequest request, HttpServletResponse response) {
//通过map查询
Map<String,Object> params = new HashMap<String,Object>();
if(!isEmpty(action.getName())){
params.put("name", action.getName());
}
if(!isEmpty(action.getIsDelete())){
params.put("isDelete", action.getIsDelete());
}
//分页查询
Pager<Action> pagers = actionService.findByMap(params);
*/
@RequestMapping(value = "/findByMap.json", method = RequestMethod.GET)
@ResponseBody
public String findByMapMap(Manage manage, Model model, HttpServletRequest request, HttpServletResponse response) {
//通过map查询
Map<String,Object> params = new HashMap<String,Object>();
if(!isEmpty(manage.getUserName())){
params.put("userName", manage.getUserName());
}
if(!isEmpty(manage.getPassWord())){
params.put("passWord", manage.getPassWord());
}
if(!isEmpty(manage.getNickName())){
params.put("nickName", manage.getNickName());
}
if(!isEmpty(manage.getIsDelete())){
params.put("isDelete", manage.getIsDelete());
}
//分页查询
Pager<Manage> pagers = manageService.findByMap(params);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("pagers", pagers);
jsonObject.put("obj", manage);
return jsonObject.toString();
}
/**
* ajax 添加
* @param
* @return
*/
@RequestMapping(value = "/exAdd.json", method = RequestMethod.POST)
@ResponseBody
public String exAddJson(Manage manage, Model model, HttpServletRequest request, HttpServletResponse response) {
manageService.insert(manage);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("message", "添加成功");
return jsonObject.toString();
}
/**
* ajax 修改
* @param
* @return
*/
@RequestMapping(value = "/exUpdate.json",method = RequestMethod.POST)
@ResponseBody
public String exUpdateJson(Manage manage, Model model, HttpServletRequest request, HttpServletResponse response) {
manageService.update(manage);
JSONObject jsonObject = JsonUtil2.getJsonObject();
jsonObject.put("message", "修改成功");
return jsonObject.toString();
*/
@RequestMapping(value = "/saveFile")
public String saveFile(@RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request, Model model) {
System.out.println("开始");
String path = request.getSession().getServletContext().getRealPath("/upload");
String fileName = file.getOriginalFilename();
System.out.println(path);
File targetFile = new File(path, fileName);
if(!targetFile.exists()){
targetFile.mkdirs();
}
//保存
try {
file.transferTo(targetFile);
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
/**
* springMvc多文件上传
* @param files
* @param id
* @return
*/
@RequestMapping(value = "/saveFiles")
public String saveFiles(@RequestParam("file") CommonsMultipartFile[] files,Integer id,HttpServletRequest request){
for(int i = 0;i<files.length;i++){
System.out.println("fileName---------->" + files[i].getOriginalFilename());
if(!files[i].isEmpty()){
int pre = (int) System.currentTimeMillis();
try {
//拿到输出流,同时重命名上传的文件
String filePath = request.getRealPath("/upload");
File f=new File(filePath);
if(!f.exists()){
f.mkdirs();
}
String fileNmae=new Date().getTime() + files[i].getOriginalFilename();
File file=new File(filePath+"/"+pre + files[i].getOriginalFilename());
if(!file.exists()){
file.createNewFile();