• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java InternalResourceView类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.web.servlet.view.InternalResourceView的典型用法代码示例。如果您正苦于以下问题:Java InternalResourceView类的具体用法?Java InternalResourceView怎么用?Java InternalResourceView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



InternalResourceView类属于org.springframework.web.servlet.view包,在下文中一共展示了InternalResourceView类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: autoCompleteShouldReturnJson

import org.springframework.web.servlet.view.InternalResourceView; //导入依赖的package包/类
@Test
public void autoCompleteShouldReturnJson() throws Exception {

	integrationMvc = standaloneSetup(new SolrController(productService))
			.setSingleView(new InternalResourceView("/products/search.html")).build();

	MvcResult result = integrationMvc
			.perform(get(String.format("/products/autocomplete?term=%s", AUTOCOMPLETE_FRAGMENT))
					.accept(MediaType.APPLICATION_JSON_UTF8))
			.andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andReturn();

	// Using Jackson ObjectMapper on JSON
	//
	// ObjectMapper mapper = new ObjectMapper();
	// List<String> fragments = Arrays.asList(mapper.readValue(body, String[].class));

	String body = result.getResponse().getContentAsString();
	String[] fragments = body.replaceAll("[\\p{Ps}\\p{Pe}\\\"]", "").split(",");

	for (String string : fragments) {
		assert(string.contains(AUTOCOMPLETE_FRAGMENT));
	}
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:24,代码来源:SolrProductControllerTests.java


示例2: portletModeMappingViewRenderRequestWithUnauthorizedUserRole

import org.springframework.web.servlet.view.InternalResourceView; //导入依赖的package包/类
@Test
public void portletModeMappingViewRenderRequestWithUnauthorizedUserRole() throws Exception {
	MockRenderRequest request = new MockRenderRequest();
	MockRenderResponse response = new MockRenderResponse();
	request.setPortletMode(PortletMode.VIEW);
	request.addUserRole("role3");
	request.setParameter("action", "not mapped");
	request.setParameter("myParam", "not mapped");
	complexDispatcherPortlet.doDispatch(request, response);
	Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
	Exception exception = (Exception) model.get("exception");
	assertNotNull(exception);
	assertTrue(exception.getClass().equals(PortletSecurityException.class));
	InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
	assertEquals("failed-default-1", view.getBeanName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:DispatcherPortletTests.java


示例3: noDetectAllHandlerMappingsWithParameterRenderRequest

import org.springframework.web.servlet.view.InternalResourceView; //导入依赖的package包/类
@Test
public void noDetectAllHandlerMappingsWithParameterRenderRequest() throws Exception {
	DispatcherPortlet complexDispatcherPortlet = new DispatcherPortlet();
	complexDispatcherPortlet.setContextClass(ComplexPortletApplicationContext.class);
	complexDispatcherPortlet.setNamespace("test");
	complexDispatcherPortlet.setDetectAllHandlerMappings(false);
	complexDispatcherPortlet.init(new MockPortletConfig(getPortletContext(), "complex"));
	MockRenderRequest request = new MockRenderRequest();
	MockRenderResponse response = new MockRenderResponse();
	request.setParameter("myParam", "test1");
	complexDispatcherPortlet.doDispatch(request, response);
	Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
	Exception exception = (Exception) model.get("exception");
	assertTrue(exception.getClass().equals(NoHandlerFoundException.class));
	InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
	assertEquals("failed-unavailable", view.getBeanName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:DispatcherPortletTests.java


示例4: generateMetadata

import org.springframework.web.servlet.view.InternalResourceView; //导入依赖的package包/类
@RequestMapping( value = "/generate" )
public ModelAndView generateMetadata(HttpServletRequest request) throws KeyStoreException
{

    ModelAndView model = new ModelAndView( new InternalResourceView( "/WEB-INF/security/metadataGenerator.jsp",
        true ) );
    MetadataForm defaultForm = new MetadataForm();

    model.addObject( "availableKeys", getAvailablePrivateKeys() );
    defaultForm.setBaseURL( getBaseURL( request ) );
    defaultForm.setEntityId( getEntityId( request ) );
    defaultForm.setNameID( MetadataGenerator.defaultNameID.toArray( new String[MetadataGenerator.defaultNameID
        .size()] ) );

    model.addObject( "metadata", defaultForm );
    return model;

}
 
开发者ID:shawnmckinney,项目名称:fortress-saml-demo,代码行数:19,代码来源:MetadataController.java


示例5: handleContext

import org.springframework.web.servlet.view.InternalResourceView; //导入依赖的package包/类
@Override
protected ModelAndView handleContext(String contextName, Context context,
    HttpServletRequest request, HttpServletResponse response) throws Exception {
  try {
    if (request.getContextPath().equals(contextName)) {
      throw new IllegalStateException(
          getMessageSourceAccessor().getMessage("probe.src.contextAction.cannotActOnSelf"));
    }

    getContainerWrapper().getTomcatContainer().remove(contextName);
    // Logging action
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    // get username logger
    String name = auth.getName();
    logger.info(getMessageSourceAccessor().getMessage("probe.src.log.undeploy"), name,
        contextName);

  } catch (Exception e) {
    request.setAttribute("errorMessage", e.getMessage());
    logger.error("Error during undeploy of '{}'", contextName, e);
    return new ModelAndView(new InternalResourceView(
        getFailureViewName() == null ? getViewName() : getFailureViewName()));
  }
  return new ModelAndView(new RedirectView(request.getContextPath() + getViewName()));
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:26,代码来源:BaseUndeployContextController.java


示例6: handleContext

import org.springframework.web.servlet.view.InternalResourceView; //导入依赖的package包/类
@Override
protected ModelAndView handleContext(String contextName, Context context,
    HttpServletRequest request, HttpServletResponse response) throws Exception {

  try {
    if (request.getContextPath().equals(contextName)) {
      throw new IllegalStateException(
          getMessageSourceAccessor().getMessage("probe.src.contextAction.cannotActOnSelf"));
    }

    executeAction(contextName);
  } catch (Exception e) {
    request.setAttribute("errorMessage", e.getMessage());
    logger.error("Error during invocation", e);
    return new ModelAndView(new InternalResourceView(getViewName()));
  }
  return new ModelAndView(new RedirectView(request.getContextPath() + getViewName()
      + (isPassQueryString() ? "?" + request.getQueryString() : "")));
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:20,代码来源:AbstractNoSelfContextHandlerController.java


示例7: testNoDetectAllHandlerMappingsWithParameterRenderRequest

import org.springframework.web.servlet.view.InternalResourceView; //导入依赖的package包/类
public void testNoDetectAllHandlerMappingsWithParameterRenderRequest() throws Exception {
	DispatcherPortlet complexDispatcherPortlet = new DispatcherPortlet();
	complexDispatcherPortlet.setContextClass(ComplexPortletApplicationContext.class);
	complexDispatcherPortlet.setNamespace("test");
	complexDispatcherPortlet.setDetectAllHandlerMappings(false);
	complexDispatcherPortlet.init(new MockPortletConfig(getPortletContext(), "complex"));
	MockRenderRequest request = new MockRenderRequest();
	MockRenderResponse response = new MockRenderResponse();
	request.setParameter("myParam", "test1");
	complexDispatcherPortlet.doDispatch(request, response);
	Map model = (Map) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
	Exception exception = (Exception) model.get("exception");
	assertTrue(exception.getClass().equals(NoHandlerFoundException.class));
	InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
	assertEquals("failed-unavailable", view.getBeanName());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:17,代码来源:DispatcherPortletTests.java


示例8: handleRequestInternal

import org.springframework.web.servlet.view.InternalResourceView; //导入依赖的package包/类
public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {

        String contextName = ServletRequestUtils.getStringParameter(request, "context", null);

        if (contextName != null) {
            try {
                if (getContainerWrapper().getTomcatContainer().installContext(contextName)) {
                    request.setAttribute("successMessage", getMessageSourceAccessor().getMessage("probe.src.deploy.context.success", new Object[]{contextName}));
                } else {
                    request.setAttribute("errorMessage", getMessageSourceAccessor().getMessage("probe.src.deploy.context.failure", new Object[]{contextName}));
                }
            } catch (Exception e) {
                request.setAttribute("errorMessage", e.getMessage());
            }
        }

        return new ModelAndView(new InternalResourceView(getViewName()));
    }
 
开发者ID:andresol,项目名称:psi-probe-plus,代码行数:19,代码来源:DeployContextController.java


示例9: handleContext

import org.springframework.web.servlet.view.InternalResourceView; //导入依赖的package包/类
protected ModelAndView handleContext(String contextName, Context context,
                                         HttpServletRequest request, HttpServletResponse response) throws Exception {
    try {
        if (request.getContextPath().equals(contextName)) {
            throw new IllegalStateException(getMessageSourceAccessor().getMessage("probe.src.contextAction.cannotActOnSelf"));
        }

        getContainerWrapper().getTomcatContainer().remove(contextName);

    } catch (Exception e) {
        request.setAttribute("errorMessage", e.getMessage());
        logger.error(e);
        return new ModelAndView(new InternalResourceView(getFailureViewName() == null ? getViewName() : getFailureViewName()));
    }
    return new ModelAndView(new RedirectView(request.getContextPath() + getViewName()));
}
 
开发者ID:andresol,项目名称:psi-probe-plus,代码行数:17,代码来源:UndeployContextController.java


示例10: handleRequestInternal

import org.springframework.web.servlet.view.InternalResourceView; //导入依赖的package包/类
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String[] sidWebApps = ServletRequestUtils.getStringParameters(request, "sid_webapp");
    for (int i = 0; i < sidWebApps.length; i++) {
        if (sidWebApps[i] != null) {
            String[] ss = sidWebApps[i].split(";");
            if (ss.length == 2) {
                String sessionId = ss[0];
                String appName = ss[1];
                Context context = getContainerWrapper().getTomcatContainer().findContext(appName);
                if (context != null) {
                    Manager manager = context.getManager();
                    Session session = manager.findSession(sessionId);
                    if (session != null && session.isValid()) {
                        session.expire();
                    }
                } else {
                    return new ModelAndView("errors/paramerror");
                }
            } else {
                return new ModelAndView("errors/paramerror");
            }
        }
    }
    return new ModelAndView(new InternalResourceView(getViewName()));
}
 
开发者ID:andresol,项目名称:psi-probe-plus,代码行数:26,代码来源:ExpireSessionsController.java


示例11: buildView

import org.springframework.web.servlet.view.InternalResourceView; //导入依赖的package包/类
/**
 * Uses the viewName and the theme associated with the service.
 * being requested and returns the appropriate view.
 * @param viewName the name of the view to be resolved
 * @return a theme-based UrlBasedView
 * @throws Exception an exception
 */
@Override
protected AbstractUrlBasedView buildView(final String viewName) throws Exception {
    final RequestContext requestContext = RequestContextHolder.getRequestContext();
    final WebApplicationService service = WebUtils.getService(requestContext);
    final RegisteredService registeredService = this.servicesManager.findServiceBy(service);

    final String themeId = service != null && registeredService != null
            && registeredService.getAccessStrategy().isServiceAccessAllowed()
            && StringUtils.hasText(registeredService.getTheme()) ? registeredService.getTheme() : defaultThemeId;

    final String themePrefix = String.format("%s/%s/ui/", pathPrefix, themeId);
    LOGGER.debug("Prefix {} set for service {} with theme {}", themePrefix, service, themeId);

    //Build up the view like the base classes do, but we need to forcefully set the prefix for each request.
    //From UrlBasedViewResolver.buildView
    final InternalResourceView view = (InternalResourceView) BeanUtils.instantiateClass(getViewClass());
    view.setUrl(themePrefix + viewName + getSuffix());
    final String contentType = getContentType();
    if (contentType != null) {
        view.setContentType(contentType);
    }
    view.setRequestContextAttribute(getRequestContextAttribute());
    view.setAttributesMap(getAttributesMap());

    //From InternalResourceViewResolver.buildView
    view.setAlwaysInclude(false);
    view.setExposeContextBeansAsAttributes(false);
    view.setPreventDispatchLoop(true);

    LOGGER.debug("View resolved: {}", view.getUrl());

    return view;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:41,代码来源:RegisteredServiceThemeBasedViewResolver.java


示例12: badSimplyQueryShouldDisplayError

import org.springframework.web.servlet.view.InternalResourceView; //导入依赖的package包/类
@Test
public void badSimplyQueryShouldDisplayError() throws Exception {

	integrationMvc = standaloneSetup(new SolrController(productService))
			.setSingleView(new InternalResourceView("/WEB-INF/views/products/list.html")).build();

	integrationMvc.perform(get("/products/list").param("query", "name1:memory")).andExpect(status().isOk())
			.andExpect(model().attributeHasFieldErrorCode("userQuery", "query", "product.search.error"))
			.andExpect(view().name("products/search"));

}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:12,代码来源:SolrProductControllerTests.java


示例13: badLocationShouldThrowGeoLocationException

import org.springframework.web.servlet.view.InternalResourceView; //导入依赖的package包/类
@Test
public void badLocationShouldThrowGeoLocationException() {
	
	integrationMvc = standaloneSetup(new SolrController(productService))
			.setSingleView(new InternalResourceView("/WEB-INF/views/products/map.html")).build();
	
	try {
		integrationMvc.perform(get("/products/map/bad")).andDo(print()).andReturn();
	} catch (Exception ex) {
		Assert.assertTrue(ex.getCause() instanceof GeoLocationException);
	}
}
 
开发者ID:mintster,项目名称:nixmash-blog,代码行数:13,代码来源:SolrProductControllerTests.java


示例14: portletModeParameterMappingInvalidHelpRenderRequest

import org.springframework.web.servlet.view.InternalResourceView; //导入依赖的package包/类
@Test
public void portletModeParameterMappingInvalidHelpRenderRequest() throws Exception {
	MockRenderRequest request = new MockRenderRequest();
	MockRenderResponse response = new MockRenderResponse();
	request.setPortletMode(PortletMode.HELP);
	request.setParameter("action", "help3");
	complexDispatcherPortlet.doDispatch(request, response);
	Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
	assertTrue(model.get("exception").getClass().equals(NoHandlerFoundException.class));
	InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
	assertEquals("failed-unavailable", view.getBeanName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:DispatcherPortletTests.java


示例15: portletModeMappingValidViewRenderRequest

import org.springframework.web.servlet.view.InternalResourceView; //导入依赖的package包/类
@Test
public void portletModeMappingValidViewRenderRequest() throws Exception {
	MockRenderRequest request = new MockRenderRequest();
	MockRenderResponse response = new MockRenderResponse();
	request.setPortletMode(PortletMode.VIEW);
	request.addUserRole("role2");
	request.setParameter("action", "not mapped");
	request.setParameter("myParam", "not mapped");
	complexDispatcherPortlet.doDispatch(request, response);
	Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
	assertEquals("view was here", model.get("result"));
	InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
	assertEquals("someViewName", view.getBeanName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:DispatcherPortletTests.java


示例16: unknownHandlerRenderRequest

import org.springframework.web.servlet.view.InternalResourceView; //导入依赖的package包/类
@Test
public void unknownHandlerRenderRequest() throws Exception {
	MockRenderRequest request = new MockRenderRequest();
	MockRenderResponse response = new MockRenderResponse();
	request.setParameter("myParam", "unknown");
	complexDispatcherPortlet.doDispatch(request, response);
	Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
	Exception exception = (Exception)model.get("exception");
	assertTrue(exception.getClass().equals(PortletException.class));
	assertTrue(exception.getMessage().indexOf("No adapter for handler") != -1);
	InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
	assertEquals("failed-default-1", view.getBeanName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:DispatcherPortletTests.java


示例17: incorrectLocaleInRequest

import org.springframework.web.servlet.view.InternalResourceView; //导入依赖的package包/类
@Test
public void incorrectLocaleInRequest() throws Exception {
	MockRenderRequest request = new MockRenderRequest();
	MockRenderResponse response = new MockRenderResponse();
	request.setParameter("myParam", "requestLocaleChecker");
	request.addPreferredLocale(Locale.ENGLISH);
	complexDispatcherPortlet.doDispatch(request, response);
	Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
	Exception exception = (Exception) model.get("exception");
	assertTrue(exception.getClass().equals(PortletException.class));
	assertEquals("Incorrect Locale in RenderRequest", exception.getMessage());
	InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
	assertEquals("failed-default-1", view.getBeanName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:DispatcherPortletTests.java


示例18: incorrectLocaleInLocalContextHolder

import org.springframework.web.servlet.view.InternalResourceView; //导入依赖的package包/类
@Test
public void incorrectLocaleInLocalContextHolder() throws Exception {
	MockRenderRequest request = new MockRenderRequest();
	MockRenderResponse response = new MockRenderResponse();
	request.setParameter("myParam", "contextLocaleChecker");
	request.addPreferredLocale(Locale.ENGLISH);
	complexDispatcherPortlet.doDispatch(request, response);
	Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
	Exception exception = (Exception) model.get("exception");
	assertTrue(exception.getClass().equals(PortletException.class));
	assertEquals("Incorrect Locale in LocaleContextHolder", exception.getMessage());
	InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
	assertEquals("failed-default-1", view.getBeanName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:DispatcherPortletTests.java


示例19: handlerInterceptorNotClearingModelAndView

import org.springframework.web.servlet.view.InternalResourceView; //导入依赖的package包/类
@Test
public void handlerInterceptorNotClearingModelAndView() throws Exception {
	MockRenderRequest request = new MockRenderRequest();
	MockRenderResponse response = new MockRenderResponse();
	request.setPortletMode(PortletMode.VIEW);
	request.addUserRole("role1");
	request.addParameter("noView", "false");
	complexDispatcherPortlet.doDispatch(request, response);
	Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
	assertEquals("view was here", model.get("result"));
	InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
	assertEquals("someViewName", view.getBeanName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:DispatcherPortletTests.java


示例20: handlerInterceptorClearingModelAndView

import org.springframework.web.servlet.view.InternalResourceView; //导入依赖的package包/类
@Test
public void handlerInterceptorClearingModelAndView() throws Exception {
	MockRenderRequest request = new MockRenderRequest();
	MockRenderResponse response = new MockRenderResponse();
	request.setPortletMode(PortletMode.VIEW);
	request.addUserRole("role1");
	request.addParameter("noView", "true");
	complexDispatcherPortlet.doDispatch(request, response);
	Map<?, ?> model = (Map<?, ?>) request.getAttribute(ViewRendererServlet.MODEL_ATTRIBUTE);
	assertNull(model);
	InternalResourceView view = (InternalResourceView) request.getAttribute(ViewRendererServlet.VIEW_ATTRIBUTE);
	assertNull(view);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:DispatcherPortletTests.java



注:本文中的org.springframework.web.servlet.view.InternalResourceView类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FurnaceSmeltEvent类代码示例发布时间:2022-05-21
下一篇:
Java TextDelimited类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap