上一篇已经大致介绍了该项目的结构以及后台部分的管理和界面
具体链接如下:
基于SSM的网上商城(上)
代码链接
这篇来讲讲前台管理和界面的一些内容:
一:前台的展示界面:
1.common公共界面
(1).common/header.jsp头部的界面
(2).common/error.jsp错误404界面
(3).common/footer.jsp底部界面
(4).common/user_menu.jsp用户使用管理界面
2.index主界面
(1).index/login.jsp登陆界面
(2).index/index.jsp显示的主界面
(3).index/register.jsp注册信息界面
3.user用户信息界面
(1).user/info.jsp用户基本信息界面
(2).user/update_pwd.jsp修改用户密码界面
4.product产品信息界面
(1).product/detail.jsp商品详情界面
(2).product/list.jsp侧边栏推荐商品
(3).product/search.jsp搜索商品界面
5.order评论界面
(1).order/list.jsp评论界面
(2).order/list.jsp订单列表界面
6.favorite收藏界面
(1).favorite/list.jsp收藏列表界面
7.commont评价列表
(1).commont/list.jsp评价列表界面
8.cart购物车界面
(1).cart/list.jsp空购物车界面
(2).cart/list_2.jsp有内容购物车界面
(3).cart/order_success.jsp下单成功界面
9.address管理收货地址
(1).address/list.jsp管理收货地址界面
二:前台的控制器:
1.AddressController前台收获地址控制器
@RequestMapping("/address")
@Controller
public class AddressController {
@Autowired
private AccountService accountService;
@Autowired
private ProductCategoryService productCategoryService;
@Autowired
private ProductService productService;
@Autowired
private AddressService addressService;
2.CartController前台购物车控制器
@RequestMapping("/cart")
@Controller
public class CartController {
@Autowired
private AccountService accountService;
@Autowired
private ProductCategoryService productCategoryService;
@Autowired
private ProductService productService;
@Autowired
private CartService cartService;
@Autowired
private AddressService addressService;
3.FavoriteController前台收藏控制器
@RequestMapping("/favorite")
@Controller
public class FavoriteController {
@Autowired
private AccountService accountService;
@Autowired
private ProductCategoryService productCategoryService;
@Autowired
private ProductService productService;
@Autowired
private FavoriteService favoriteService;
4.HomeCommenController前台评价控制器
@RequestMapping("/comment")
@Controller
public class HomeCommentController {
@Autowired
private AccountService accountService;
@Autowired
private ProductCategoryService productCategoryService;
@Autowired
private ProductService productService;
@Autowired
private CommentService commentService;
5.HomeOrderController前台订单控制器
@RequestMapping("/order")
@Controller
public class HomeOrderController {
@Autowired
private AccountService accountService;
@Autowired
private ProductCategoryService productCategoryService;
@Autowired
private ProductService productService;
@Autowired
private OrderService orderService;
@Autowired
private CartService cartService;
@Autowired
private AddressService addressService;
6.HomeProductController前台商品控制器
@RequestMapping("/product")
@Controller
public class HomeProductController {
@Autowired
private AccountService accountService;
@Autowired
private ProductCategoryService productCategoryService;
@Autowired
private ProductService productService;
@Autowired
private CommentService commentService;
7.HomeUserController前台用户中心控制器
@RequestMapping("/user")
@Controller
public class HomeUserController {
@Autowired
private AccountService accountService;
@Autowired
private ProductCategoryService productCategoryService;
@Autowired
private ProductService productService;
@Autowired
private OrderService orderService;
@Autowired
private CartService cartService;
@Autowired
private AddressService addressService;
8.IndexController前台首页控制器
@RequestMapping("/home")
@Controller
public class IndexController {
@Autowired
private AccountService accountService;
@Autowired
private ProductCategoryService productCategoryService;
@Autowired
private ProductService productService;
三:前台的dao层:
1.addressDao收货地址dao层
2.CartDao购物车dao层
3.FavoriteDao收藏dao层
四:前台的实体entity:
1.Address收货地址实体
@Component
public class Address {
private Long id;//id
private Long userId;//用户id
private String name;//收货人姓名
private String address;//详细地址
private String phone;//手机号码
private Date createTime;//添加时间
2.Cart购物车实体
@Component
public class Cart {
private Long id;//id
private Long productId;//商品id
private Long userId;//用户id
private String name;//商品名称
private String imageUrl;//商品主图
private Double price;//商品价格
private int num;//商品数量
private Double money;//商品价格
private Date createTime;//添加时间
3.Favorite收藏实体
@Component
public class Favorite {
private Long id;//id
private Long productId;//商品id
private Long userId;//用户id
private String name;//商品名称
private String imageUrl;//商品主图
private Double price;//商品价格
private Date createTime;//添加时间
五:前台的interceptor拦截器:
LoginInterceptor拦截器
/**
* 前台登录拦截器
* @author llq
*
*/
public class LoginInterceptor implements HandlerInterceptor {
@Override
public void afterCompletion(HttpServletRequest arg0,
HttpServletResponse arg1, Object arg2, Exception arg3)
throws Exception {
// TODO Auto-generated method stub
}
@Override
public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1,
Object arg2, ModelAndView arg3) throws Exception {
// TODO Auto-generated method stub
}
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object arg2) throws Exception {
// TODO Auto-generated method stub
String requestURI = request.getRequestURI();
Object account = request.getSession().getAttribute("account");
if(account == null){
//表示未登录或者登录失效
System.out.println("链接"+requestURI+"进入拦截器!");
String header = request.getHeader("X-Requested-With");
//判断是否是ajax请求
if("XMLHttpRequest".equals(header)){
//表示是ajax请求
Map<String, String> ret = new HashMap<String, String>();
ret.put("type", "error");
ret.put("msg", "登录会话超时或还未登录,请重新登录!");
response.getWriter().write(JSONObject.fromObject(ret).toString());
return false;
}
//表示是普通链接跳转,直接重定向到登录页面
response.sendRedirect(request.getServletContext().getContextPath() + "/home/login");
return false;
}
return true;
}
}
六:前台的service以及serviceImpl:
收货地址接口AddressService
AddressServiceimpl实现类
Service方法同上面的dao层方法
ServiceImpl实现方法类似上面,这里不再赘述!!
七:前台的mapper映射文件:
1.AddressMapper.xml收货映射文件
2.CartMapper.xml购物车映射文件
3.FavoriteMapper.xml收藏映射文件