解决方案 »

  1.   

    我在service层中是这样写的
    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public ResultJson userSave(String json) throws Exception {
    ResultJson result=null;
    try {
    User user = (User) JSON.parseObject(json, User.class);
    userDao.save(user);
    result = new ResultJson(true, "success", user);
    int i = 1 / 0;
    } catch (Exception e) {
    Logger.getRootLogger().error("save用户信息异常", e);
    throw new ServiceException(e.getMessage());
    }
    return result;
    }webservice中是
    @PUT
    @Produces({ MediaType.APPLICATION_JSON })
    @Consumes(MediaType.TEXT_PLAIN)
    @Path("/user")
    @Override
    public String save(String json) {
    ResultJson result=new ResultJson(false, "fail", null);
    try {
    result=usrService.userSave(json);
    } catch (Exception e) {
    return JSON.toJSONString(result);
    }
    return JSON.toJSONString(result);
    }但是结果并不会返回json数据,而是返回500页