提交 8de9aab4 编写于 作者: Y yingjun

修复GlobalExceptionResolver的bug

上级 fe0c3269
package com.yingjun.ssm.dao;
import java.util.List;
import java.util.Map;
import com.yingjun.ssm.entity.Goods;
import org.apache.ibatis.annotations.Param;
import org.springframework.cache.annotation.Cacheable;
import com.yingjun.ssm.entity.Goods;
import java.util.List;
import java.util.Map;
public interface GoodsDao {
/**
......
package com.yingjun.ssm.exception;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSON;
import com.yingjun.ssm.dto.BaseResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.util.WebUtils;
import com.alibaba.fastjson.JSON;
import com.yingjun.ssm.dto.BaseResult;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
/**
* 错误信息统一处理
......@@ -29,7 +26,7 @@ public class GlobalExceptionResolver implements HandlerExceptionResolver {
@ResponseBody
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
LOG.error("用户 " + WebUtils.getCookie(request, "userPhone").getValue() + " 访问" + request.getRequestURI() + " 发生错误, 错误信息:" + ex.getMessage());
LOG.error("访问" + request.getRequestURI() + " 发生错误, 错误信息:" + ex.getMessage());
//这里有2种选择
//跳转到定制化的错误页面
/*ModelAndView error = new ModelAndView("error");
......
package com.yingjun.ssm.service.impl;
import java.util.List;
import com.yingjun.ssm.cache.RedisCache;
import com.yingjun.ssm.dao.UserDao;
import com.yingjun.ssm.entity.User;
import com.yingjun.ssm.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import com.yingjun.ssm.cache.RedisCache;
import com.yingjun.ssm.dao.UserDao;
import com.yingjun.ssm.entity.Goods;
import com.yingjun.ssm.entity.User;
import com.yingjun.ssm.service.UserService;
import java.util.List;
@Service
public class UserServiceImpl implements UserService {
......
......@@ -3,14 +3,12 @@ package com.yingjun.ssm.util;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.dyuproject.protostuff.LinkedBuffer;
import com.dyuproject.protostuff.ProtostuffIOUtil;
import com.dyuproject.protostuff.Schema;
import com.dyuproject.protostuff.runtime.RuntimeSchema;
import com.yingjun.ssm.entity.User;
/**
* 序列话工具
......
package com.yingjun.ssm.web;
import java.util.List;
import com.yingjun.ssm.entity.User;
import com.yingjun.ssm.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -10,8 +10,7 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.yingjun.ssm.entity.User;
import com.yingjun.ssm.service.UserService;
import java.util.List;
@Controller
@RequestMapping("/user")
......
package com.yingjun.ssm.dao;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.yingjun.ssm.entity.Goods;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.yingjun.ssm.entity.Goods;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:spring/spring-dao.xml")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册