这篇文章主要为大家展示了“Java如何实现在线购书商城系统”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“Java如何实现在线购书商城系统”这篇文章吧。
一、项目简述
功能:一个基于JavaWeb的网上书店的设计与实现,归纳 出了几个模块,首先是登录注册模块,图书查找模块,购 物车模块,订单模块,个人中心模块,用户管理模块,图 书管理模块等。 该项目是javaJeb技术的实战操作,采用了MVC设计模 式,包括基本的entity, jscript, servlet,以及ajax异步请 求,查询分页,持久化层方法的封装等等,对javaweb技 术的巩固很有帮助,为J2EE的学习打下基础,适用于课程 设计,毕业设计。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。
项目技术: JSP + Entity+ Servlert + html+ css + JavaScript + JQuery + Ajax + Fileupload 等等。
书信息管理代码:
书信息管理: @Controller@RequestMapping("/book")public class BookInfoController { @Autowired private IBookInfoService bookInfoService; @Autowired private BookDescMapper bookDescMapper; @RequestMapping("/info/{bookId}") public String bookInfo(@PathVariable("bookId") Integer bookId, Model model) throws BSException { //查询书籍 BookInfo bookInfo = bookInfoService.findById(bookId); //查询书籍推荐列表 List<BookInfo> recommendBookList = bookInfoService.findBookListByCateId(bookInfo.getBookCategoryId(), 1, 5); //查询书籍详情 BookDesc bookDesc = bookDescMapper.selectByPrimaryKey(bookId); //增加访问量 bookInfoService.addLookMount(bookInfo); Collections.shuffle(recommendBookList); model.addAttribute("bookInfo", bookInfo); model.addAttribute("bookDesc", bookDesc); model.addAttribute("recommendBookList", recommendBookList); return "book_info"; } @RequestMapping("/list") public String bookSearchList(@RequestParam(defaultValue = "", required = false) String keywords, @RequestParam(defaultValue = "0", required = false) int cateId,//分类Id,默认为0,即不按照分类Id查 @RequestParam(defaultValue = "1", required = false) int page, @RequestParam(defaultValue = "6", required = false) int pageSize, Model model) { keywords = keywords.trim(); PageInfo<BookInfo> bookPageInfo = bookInfoService.findBookListByCondition(keywords, cateId, page, pageSize,0);//storeId为0,不按照商店Id查询 model.addAttribute("bookPageInfo", bookPageInfo); model.addAttribute("keywords", keywords); model.addAttribute("cateId", cateId); return "book_list"; } }
shiro安全框架配置代码:
@Configurationpublic class ShiroConfig { @Bean(name = "lifecycleBeanPostProcessor") public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() { return new LifecycleBeanPostProcessor(); } @Bean public SecurityManager securityManager(EhCacheManager ehCacheManager) { DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); securityManager.setRealm(myShiroRealm()); //securityManager.setRememberMeManager(rememberMeManager()); securityManager.setCacheManager(ehCacheManager); return securityManager; } @Bean public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager) { ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean(); shiroFilterFactoryBean.setSecurityManager(securityManager); Map<String, String> filterChainDefinitionMap = new LinkedHashMap<>(); //拦截器 filterChainDefinitionMap.put("/img @Bean public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager){ AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor(); authorizationAttributeSourceAdvisor.setSecurityManager(securityManager); return authorizationAttributeSourceAdvisor; } @Bean public DefaultAdvisorAutoProxyCreator getDefaultAdvisorAutoProxyCreator() { DefaultAdvisorAutoProxyCreator daap = new DefaultAdvisorAutoProxyCreator(); daap.setProxyTargetClass(true); return daap; } @Bean public HashedCredentialsMatcher hashedCredentialsMatcher() { HashedCredentialsMatcher hashedCredentialsMatcher = new HashedCredentialsMatcher(); hashedCredentialsMatcher.setHashAlgorithmName("md5");//散列算法:这里使用MD5算法; hashedCredentialsMatcher.setHashIterations(1);//散列的次数,比如散列两次,相当于 md5(md5("")); return hashedCredentialsMatcher; } @Bean @DependsOn("lifecycleBeanPostProcessor") public EhCacheManager ehCacheManager(CacheManager cacheManager) { EhCacheManager em = new EhCacheManager(); //将ehcacheManager转换成shiro包装后的ehcacheManager对象 em.setCacheManager(cacheManager); em.setCacheManagerConfigFile("classpath:ehcache.xml"); return em; }}
以上是“Java如何实现在线购书商城系统”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注编程网行业资讯频道!