Java tutorial
/** * Project: guahao-portal-web-home * * File Created at 2012-11-21 * * Copyright 2012 Greenline.com Corporation Limited. * All rights reserved. * * This software is the confidential and proprietary information of * Greenline Company. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Greenline.com. */ package com.greenline.guahao.web.module.common.exception; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringUtils; import org.springframework.web.servlet.ModelAndView; import com.greenline.framework.mursi.web.servlet.handler.MursiExceptionResolver; import com.greenline.guahao.web.module.common.utils.CommonUtils; import com.greenline.guahao.web.module.common.utils.DomainFilter; /** * @Type PortalExceptionResolver * @Desc portal??? * @author jianyun.zheng * @date 2012-11-21 * @Version V1.0 */ public class PortalExceptionResolver extends MursiExceptionResolver { @Resource private DomainFilter domainFilter; @Override public ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { logger.error("url=" + (request.getServerName() + CommonUtils.getBeforeRepath(request))); // ? ModelAndView mv = super.doResolveException(request, response, handler, ex); mv.setViewName(domainFilter.getAuthorization(request).getErrorViewName(request, response)); response.setStatus(HttpServletResponse.SC_OK); String servername = (String) request.getAttribute("servername"); if (StringUtils.isNotBlank(servername)) { // ???url 0 1? String domain_showurl = (String) request.getAttribute("domain_showurl"); if (StringUtils.isNotBlank(domain_showurl) && "0".equals(domain_showurl)) { String domainservername = request.getScheme() + "://" + servername + CommonUtils.getServerPort(request); mv.getModelMap().put("guahaoServer", domainservername); } } return mv; } }