Java项目:SSM企业门户网站

作者主页:夜未央5788

 简介:Java领域优质创作者、Java项目、学习资料、技术互助

文末获取源码

项目介绍

本项目分为前后台,前台主要用于官网展示,后台主要为管理员管理,

管理员角色包含以下功能:
管理员登录,文章分类管理,文章列表管理,友情链接管理,招聘管理,留言管理,滚动图片管理,联系我们,关于我们,网站管理员管理,日志管理等功能。

用户角色包含以下功能:

用户首页,关于我们,服务领域发布,新闻动态,诚聘英才,在线留言,联系我们等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 

5.数据库:MySql 5.7版本;

6.是否Maven项目:是;

技术栈

1. 后端:Spring+SpringMVC+Mybatis

2. 前端:JSP+CSS+JavaScript+bootstrap+jquery

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;

2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;

3. 将项目中conf.properties配置文件中的数据库配置改为自己的配置;

4. 运行项目,输入localhost:8080/ 登录

运行截图

前台界面

 

 

 

 

 

管理端页面

 

 

 

 

 

代码相关

文章管理控制器

@Controller("frontArticleController")
@RequestMapping("/")
public class ArticleAction extends BaseController<Article>{
    private static final String page_toList = "/front/article/articleList";
    private static final String page_toEdit = "/front/article/articleInfo";

    @Autowired
    private ArticleService articleService;
    @Override
    public Services<Article> getService() {
        return articleService;
    }
    public ArticleAction(){
        super.page_toList = page_toList;
        super.page_toEdit = page_toEdit;
    }

    /**
     * 跳转到文章列表
     * @param request
     * @param article
     * @return
     * @throws Exception
     */
    @RequestMapping("article")
    public String article(HttpServletRequest request, @ModelAttribute("e") Article article) throws Exception {

        this.initPageSelect();
        setParamWhenInitQuery(article);
        int offset = 0;
        if(request.getParameter("pager.offset")!=null){
            offset = Integer.parseInt(request.getParameter("pager.offset"));
        }
        if(offset < 0){
            offset=0;
        }
        article.setOffset(offset);

        PageModel page = getService().selectPageList(article);
        if(page == null){
            page = new PageModel();
        }
        page.setPageSize(10);    //设置单页数据为10
        page.setPagerSize((page.getTotal() + page.getPageSize() - 1)
                / page.getPageSize());
        selectListAfter(page);
        page.setPagerUrl("article");
        request.setAttribute("pager", page);
        return page_toList;
    }


    /**
     * 文章详情
     * @param code
     * @param model
     * @return
     * @throws Exception
     */
    @RequestMapping("article/{code}")
    public String selectOne(HttpServletRequest request,@ModelAttribute("code")@PathVariable("code") String code,@ModelAttribute("e") Article article, ModelMap model) throws Exception {
        if(isInteger(code)) {   //如果是数字   则为id   按id进行文章查询
            Article e = articleService.selectById(Integer.parseInt(code));
            e.setHit(String.valueOf(Integer.parseInt(e.getHit())+1));
            articleService.update(e);       //更新浏览量     --优化建议:可使用缓存或者redis暂存  然后再刷入数据库
            Article next = articleService.selectNext(Integer.parseInt(code));
            if(next==null){
                next = new Article();
            }
            Article previous = articleService.selectPrevious(Integer.parseInt(code));
            if(previous==null){
                previous = new Article();
            }
            model.addAttribute("e", e);
            model.addAttribute("next", next);
            model.addAttribute("previous", previous);
            return page_toEdit;
        }else{//不是数字,则为分类编码
            for(ArticleCategory item: SystemManage.getInstance().getArticleCategory()){ //遍历分类缓存
                if(code.equals(item.getCode())){        //当编码相等时
                    article.setCategoryId(String.valueOf(item.getId()));    //把相等编码里的分类id值赋予文章中catagroyId中
                    break;  //跳出循环
                }
            }
            setParamWhenInitQuery(article);
            int offset = 0;
            if(request.getParameter("pager.offset")!=null){
                offset = Integer.parseInt(request.getParameter("pager.offset"));
            }
            if(offset < 0){
                offset=0;
            }
            article.setOffset(offset);
            PageModel page = getService().selectPageList(article);
            if(page == null){
                page = new PageModel();
            }
            page.setPageSize(10);    //设置单页数据为10
            page.setPagerSize((page.getTotal() + page.getPageSize() - 1)
                    / page.getPageSize());
            selectListAfter(page);
            page.setPagerUrl(code);
            request.setAttribute("pager", page);
            request.setAttribute("code", code);
            return page_toList;
        }

    }

    /**
     *判断是不是数字
     * @param code
     * @return
     */
    public static boolean isInteger(String code){
        try {
            Integer.parseInt(code);
            return true;
        }catch (NumberFormatException e){
            return false;
        }
    }
}

留言管理控制器

/**
 * 前台留言
 *
 * @author me
 */
@Controller("frontMessageController")
@RequestMapping("/")
public class MessagesAction {

    @Autowired
    private MessageService messageService;
    @Autowired
    private FrontCache frontCache;


    @RequestMapping("message")
    public String message() {
        return "/front/message/message";
    }

    /**
     * 前台留言
     *
     * @param e
     * @param model
     * @return
     * @throws Exception
     */
    @RequestMapping("message/leaveMessage")
    @ResponseBody
    public String leaveMessage(Messages e, ModelMap model) throws Exception {
        messageService.insert(e);
        frontCache.loadMessage();
        return "ok";
    }
    @RequestMapping("checkVcode")
    @ResponseBody
    public String checkVcode(@ModelAttribute("e") Messages e, HttpServletResponse response) throws IOException {
        String vcode = RequestHolder.getSession().getAttribute("validateCode").toString();
        if(StringUtils.isNotBlank(vcode)&&!(vcode.toLowerCase()).equals(e.getVcode().toLowerCase())){
            return "{\"error\":\"验证码不正确!\"}";
        }
        return null;
    }
}

 友情链接管理控制器

/**
 * 友情链接Action
 */
@Controller
@RequestMapping("/manage/friendLinks/")
public class FriendLinksAction extends BaseController<FriendLinks>{

	private static final String page_toEdit = "/manage/friendLinks/friendLinksEdit";
	private static final String page_toAdd = "/manage/friendLinks/friendLinksEdit";
	private static final String page_toList = "/manage/friendLinks/friendLinksList";
	public FriendLinksAction() {
		super.page_toAdd = page_toAdd;
		super.page_toEdit = page_toEdit;
		super.page_toList = page_toList;
	}
	@Autowired
	private FriendLinksService friendLinksService;
	@Autowired
	private FrontCache frontCache;
	
	@Override
	public Services<FriendLinks> getService() {
		return friendLinksService;
	}


	/**
	 * 更新
	 * @param request
	 * @param e
	 * @param flushAttrs
	 * @return
     * @throws Exception
     */
	@Override
	public String update(HttpServletRequest request, @ModelAttribute("e") FriendLinks e, RedirectAttributes flushAttrs) throws Exception {
		friendLinksService.update(e);
		insertAfter(e);
		//更新成功后更新缓存
		frontCache.loadFriendLinks();
		addMessage(flushAttrs, "操作成功!");
		return "redirect:selectList";
	}


	/**
	 * 插入
	 * @param request
	 * @param e
	 * @param flushAttrs
	 * @return
     * @throws Exception
     */
	@Override
	public String insert(HttpServletRequest request, @ModelAttribute("e") FriendLinks e, RedirectAttributes flushAttrs) throws Exception {
		friendLinksService.insert(e);
		insertAfter(e);
		//插入成功后更新缓存
		frontCache.loadFriendLinks();
		addMessage(flushAttrs,"操作成功!");
		return "redirect:selectList";
	}


}

如果也想学习本系统,下面领取。关注并回复:069ssm  

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜未央5788

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值