本文整理匯總了Java中org.springframework.web.servlet.ModelAndView.setView方法的典型用法代碼示例。如果您正苦於以下問題:Java ModelAndView.setView方法的具體用法?Java ModelAndView.setView怎麽用?Java ModelAndView.setView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.web.servlet.ModelAndView
的用法示例。
在下文中一共展示了ModelAndView.setView方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: servicePortalFind
import org.springframework.web.servlet.ModelAndView; //導入方法依賴的package包/類
@RequestMapping ( "/find-service/{releasePackage}/{serviceName}" )
public ModelAndView servicePortalFind (
@PathVariable String serviceName,
@PathVariable String releasePackage ) {
ModelAndView mav = new ModelAndView();
mav.setView( new RedirectView( CsapCoreService.ADMIN_URL, true, false, true ) );
logger.info( "Redirecting based on package {} and service {}", releasePackage, serviceName );
mav.getModel().put( CSAP.PACKAGE_PARAM, releasePackage );
// use the first instance to determine the default admin service
ServiceInstance instance = application
.serviceInstancesByName( releasePackage, serviceName )
.stream()
.findFirst()
.get();
mav.getModel().put( CSAP.SERVICE_PORT_PARAM, instance.getServiceName_Port() );
mav.getModel().put( CSAP.HOST_PARAM, instance.getHostName() );
return mav;
}
示例2: resolveException
import org.springframework.web.servlet.ModelAndView; //導入方法依賴的package包/類
@Override
public ModelAndView resolveException(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse, Object o, Exception e) {
HttpDownServer.LOGGER.error("rest error:",e);
ModelAndView modelAndView = new ModelAndView();
try {
ResultInfo resultInfo = new ResultInfo().setStatus(ResultStatus.ERROR.getCode())
.setMsg(ResultInfo.MSG_ERROR);
Map<String, Object> attr = JSON.parseObject(JSON.toJSONString(resultInfo), Map.class);
MappingJackson2JsonView view = new MappingJackson2JsonView();
view.setAttributesMap(attr);
modelAndView.setView(view);
} catch (Exception e1) {
e1.printStackTrace();
}
return modelAndView;
}
示例3: postHandle
import org.springframework.web.servlet.ModelAndView; //導入方法依賴的package包/類
@Override
public void postHandle(final HttpServletRequest request, final HttpServletResponse response,
final Object handler, final ModelAndView modelAndView) throws Exception {
if (!StringUtils.isEmpty(request.getQueryString())
&& request.getQueryString().contains(CasProtocolConstants.PARAMETER_TICKET)) {
final RedirectView v = new RedirectView(request.getRequestURL().toString());
v.setExposeModelAttributes(false);
v.setExposePathVariables(false);
modelAndView.setView(v);
}
}
示例4: postHandle
import org.springframework.web.servlet.ModelAndView; //導入方法依賴的package包/類
@Override
public void postHandle(final HttpServletRequest request, final HttpServletResponse response,
final Object handler, final ModelAndView modelAndView) throws Exception {
if (StringUtils.isNotBlank(request.getQueryString())
&& request.getQueryString().contains(CasProtocolConstants.PARAMETER_TICKET)
&& modelAndView != null) {
final RedirectView v = new RedirectView(request.getRequestURL().toString());
v.setExposeModelAttributes(false);
v.setExposePathVariables(false);
modelAndView.setView(v);
}
}
示例5: adaptException2MAV
import org.springframework.web.servlet.ModelAndView; //導入方法依賴的package包/類
private ModelAndView adaptException2MAV(Exception ex) {
ModelAndView mav = new ModelAndView();
mav.setView(new MappingJackson2JsonView());
mav.addObject("exception",ex.getClass().getSimpleName());
mav.addObject("message", ex.getMessage());
return mav;
}