当前位置: 首页>>代码示例>>Java>>正文


Java InternalResourceView.setUrl方法代码示例

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


在下文中一共展示了InternalResourceView.setUrl方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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 InternalResourceView view = (InternalResourceView) BeanUtils.instantiateClass(getViewClass());

    final String defaultThemePrefix = String.format(THEME_LOCATION_PATTERN, getPrefix(), "default");
    final String defaultViewUrl = defaultThemePrefix + viewName + getSuffix();
    view.setUrl(defaultViewUrl);

    if (service != null && registeredService != null
        && registeredService.getAccessStrategy().isServiceAccessAllowed()
        && StringUtils.hasText(registeredService.getTheme())) {

        LOGGER.debug("Attempting to locate views for service [{}] with theme [{}]",
            registeredService.getServiceId(), registeredService.getTheme());

        final String themePrefix = String.format(THEME_LOCATION_PATTERN, getPrefix(), registeredService.getTheme());
        LOGGER.debug("Prefix [{}] set for service [{}] with theme [{}]", themePrefix, service,
            registeredService.getTheme());
        final String viewUrl = themePrefix + viewName + getSuffix();

        final Resource resource = this.resourceLoader.getResource(viewUrl);
        if (resource.exists()) {
            view.setUrl(viewUrl);
        }

    }

    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,代码行数:56,代码来源:RegisteredServiceThemeBasedViewResolver.java

示例3: 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 InternalResourceView view = (InternalResourceView) BeanUtils.instantiateClass(getViewClass());

    final String defaultThemePrefix = String.format(THEME_LOCATION_PATTERN, getPrefix(), "default");
    final String defaultViewUrl = defaultThemePrefix + viewName + getSuffix();
    view.setUrl(defaultViewUrl);

    if (service != null && registeredService != null
        && registeredService.getAccessStrategy().isServiceAccessAllowed()
        && StringUtils.hasText(registeredService.getTheme())) {

        LOGGER.debug("Attempting to locate views for service [{}] with theme [{}]",
            registeredService.getServiceId(), registeredService.getTheme());

        final String themePrefix = String.format(THEME_LOCATION_PATTERN, getPrefix(), registeredService.getTheme());
        LOGGER.debug("Prefix [{}] set for service [{}] with theme [{}]", themePrefix, service,
            registeredService.getTheme());
        final String viewUrl = themePrefix + viewName + getSuffix();
        view.setUrl(viewUrl);

    }

    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:yuweijun,项目名称:cas-server-4.2.1,代码行数:52,代码来源:RegisteredServiceThemeBasedViewResolver.java

示例4: 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();
    
    /*
      add by WangXiaoJin
     */
    String themeId = useRequestParam ? requestContext.getRequestParameters().get(themeFrameKey) : null;
    if(StringUtils.isEmpty(themeId)) {
    	
    	final WebApplicationService service = WebUtils.getService(requestContext);
    	final RegisteredService registeredService = this.servicesManager.findServiceBy(service);
    	
    	themeId = service != null && registeredService != null
    			&& registeredService.getAccessStrategy().isServiceAccessAllowed()
    			&& StringUtils.hasText(registeredService.getTheme()) ? registeredService.getTheme() : defaultThemeId;
    			
    }else {
    	themeId = themeId.toLowerCase();
    }

    final String themePrefix = String.format("%s/%s/ui/", pathPrefix, 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);

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

    return view;
}
 
开发者ID:easycodebox,项目名称:easycode,代码行数:51,代码来源:CustomRegisteredServiceThemeBasedViewResolver.java


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