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


Java UrlBuilder.toString方法代码示例

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


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

示例1: getLinkToPage

import net.sourceforge.stripes.util.UrlBuilder; //导入方法依赖的package包/类
public String getLinkToPage(int page) {
    int rowsPerPage = getCrudConfiguration().getRowsPerPage();
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("sortProperty", getSortProperty());
    parameters.put("sortDirection", getSortDirection());
    parameters.put("firstResult", page * rowsPerPage);
    parameters.put("maxResults", rowsPerPage);
    if(!PageActionLogic.isEmbedded(this)) {
        parameters.put(AbstractCrudAction.SEARCH_STRING_PARAM, getSearchString());
    }

    UrlBuilder urlBuilder =
            new UrlBuilder(Locale.getDefault(), Util.getAbsoluteUrl(context.getActionPath()), false)
                    .addParameters(parameters);
    return urlBuilder.toString();
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:17,代码来源:AbstractCrudAction.java

示例2: buildUrl

import net.sourceforge.stripes.util.UrlBuilder; //导入方法依赖的package包/类
/**
 * Builds the URL based on the information currently stored in the tag. Ensures that all
 * parameters are appended into the URL, along with event name if necessary and the source
 * page information.
 *
 * @return the fully constructed URL
 * @throws StripesJspException if the base URL cannot be determined
 */
protected String buildUrl() throws StripesJspException {
    HttpServletRequest request = (HttpServletRequest) getPageContext().getRequest();
    HttpServletResponse response = (HttpServletResponse) getPageContext().getResponse();


    // Add all the parameters and reset the href attribute; pass to false here because
    // the HtmlTagSupport will HtmlEncode the ampersands for us
    String base = getPreferredBaseUrl();
    UrlBuilder builder = new UrlBuilder(pageContext.getRequest().getLocale(), base, false);
    if (this.event != VALUE_NOT_SET) {
        builder.setEvent(this.event == null || this.event.length() < 1 ? null : this.event);
    }
    if (addSourcePage) {
        builder.addParameter(StripesConstants.URL_KEY_SOURCE_PAGE,
                CryptoUtil.encrypt(request.getServletPath()));
    }
    if (this.anchor != null) {
        builder.setAnchor(anchor);
    }
    builder.addParameters(this.parameters);

    // Prepend the context path, but only if the user didn't already
    String url = builder.toString();
    String contextPath = request.getContextPath();
    if (contextPath.length() > 1) {
        boolean prepend = prependContext != null && prependContext
                || prependContext == null && beanclass != null
                || prependContext == null && url.startsWith("/") && !url.startsWith(contextPath);

        if (prepend) {
            if (url.startsWith("/"))
                url = contextPath + url;
            else
                log.warn("Use of prependContext=\"true\" is only valid with a URL that starts with \"/\"");
        }
    }

    return response.encodeURL(url);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:48,代码来源:LinkTagSupport.java

示例3: getUrl

import net.sourceforge.stripes.util.UrlBuilder; //导入方法依赖的package包/类
/**
 * Constructs the URL for the resolution by taking the path and appending any parameters
 * supplied.
 * 
 * @param locale the locale to be used by {@link Formatter}s when formatting parameters
 */
public String getUrl(Locale locale) {
    UrlBuilder builder = new UrlBuilder(locale, getPath(), false);
    if (event != VALUE_NOT_SET) {
        builder.setEvent(event == null || event.length() < 1 ? null : event);
    }
    if (anchor != null) {
        builder.setAnchor(anchor);
    }
    builder.addParameters(this.parameters);
    return builder.toString();
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:18,代码来源:OnwardResolution.java

示例4: execute

import net.sourceforge.stripes.util.UrlBuilder; //导入方法依赖的package包/类
public void execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
    if(request.getParameter("__portofino_quiet_auth_failure") != null) {
        return;
    }
    ServletContext servletContext = request.getServletContext();
    Configuration configuration =
            (Configuration) servletContext.getAttribute(BaseModule.PORTOFINO_CONFIGURATION);
    String loginPage = configuration.getString(PortofinoProperties.LOGIN_PAGE);
    if (response.getContentType() == null || response.getContentType().contains("text/html")) {
        ElementsActionBeanContext context = new ElementsActionBeanContext();
        context.setRequest(request);
        String originalPath = context.getActionPath();
        UrlBuilder urlBuilder =
                new UrlBuilder(Locale.getDefault(), originalPath, false);
        Map<?, ?> parameters = request.getParameterMap();
        urlBuilder.addParameters(parameters);
        String returnUrl = urlBuilder.toString();
        logger.info("Anonymous user not allowed to see {}. Redirecting to login.", originalPath);
        RedirectResolution redirectResolution =
                new RedirectResolution(loginPage, true);
        redirectResolution.addParameter("returnUrl", returnUrl);
        redirectResolution.execute(request, response);
    } else {
        logger.debug("AJAX call while user disconnected");
        UrlBuilder loginUrlBuilder =
                new UrlBuilder(request.getLocale(), loginPage, false);
        response.setHeader(LOGIN_PAGE_HEADER, loginUrlBuilder.toString());
        new ErrorResolution(STATUS, errorMessage).execute(request, response);
    }
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:31,代码来源:AuthenticationRequiredResolution.java

示例5: forgotPassword2

import net.sourceforge.stripes.util.UrlBuilder; //导入方法依赖的package包/类
public Resolution forgotPassword2() {
    Subject subject = SecurityUtils.getSubject();
    if (subject.isAuthenticated()) {
        logger.debug("Already logged in");
        return redirectToReturnUrl();
    }

    PortofinoRealm portofinoRealm = ShiroUtils.getPortofinoRealm();
    try {
        Serializable user = portofinoRealm.getUserByEmail(email);
        if(user != null) {
            String token = portofinoRealm.generateOneTimeToken(user);
            HttpServletRequest req = context.getRequest();
            String url = req.getRequestURL().toString();
            UrlBuilder urlBuilder = new UrlBuilder(Locale.getDefault(), url, true);
            urlBuilder.setEvent("resetPassword");
            urlBuilder.addParameter("token", token);

            String siteUrl = ServletUtils.getApplicationBaseUrl(req);
            String changePasswordLink = urlBuilder.toString();

            String body = getResetPasswordEmailBody(siteUrl, changePasswordLink);

            String from = portofinoConfiguration.getString(
                    PortofinoProperties.MAIL_FROM, "[email protected]");
            sendForgotPasswordEmail(
                    from, email, ElementsThreadLocals.getText("password.reset.confirmation.required"), body);
        } else {
            logger.warn("Forgot password request for nonexistent email");
        }

        //This is by design, for better security. Always give the successful message even if no mail was sent. 
        SessionMessages.addInfoMessage(ElementsThreadLocals.getText("check.your.mailbox.and.follow.the.instructions"));
    } catch (Exception e) {
        logger.error("Error during password reset", e);
        SessionMessages.addErrorMessage(ElementsThreadLocals.getText("password.reset.failed"));
    }
    return new RedirectResolution(context.getActionPath());
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:40,代码来源:LoginAction.java

示例6: getBlobDownloadUrl

import net.sourceforge.stripes.util.UrlBuilder; //导入方法依赖的package包/类
public String getBlobDownloadUrl(AbstractBlobField field) {
    UrlBuilder urlBuilder = new UrlBuilder(
            Locale.getDefault(), Util.getAbsoluteUrl(context.getActionPath()), false)
            .addParameter("downloadBlob", "")
            .addParameter("propertyName", field.getPropertyAccessor().getName());
    return urlBuilder.toString();
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:8,代码来源:AbstractCrudAction.java

示例7: execute

import net.sourceforge.stripes.util.UrlBuilder; //导入方法依赖的package包/类
@DefaultHandler
public Resolution execute() {
    if(chartConfiguration == null) {
        return forwardToPageActionNotConfigured();
    }

    try {
        // Run/generate the chart
        try {
            Thread.currentThread().setContextClassLoader(Class.class.getClassLoader());
            generateChart();
        } finally {
            Thread.currentThread().setContextClassLoader(JFreeChartAction.class.getClassLoader());
        }

        chartId = RandomUtil.createRandomId();

        String actionurl = context.getActionPath();
        UrlBuilder chartResolution =
                new UrlBuilder(context.getLocale(), actionurl, false)
                        .addParameter("chartId", chartId)
                        .addParameter("chart", "");
        String url = context.getRequest().getContextPath() + chartResolution.toString();

        file = RandomUtil.getTempCodeFile(CHART_FILENAME_FORMAT, chartId);

        jfreeChartInstance =
                new JFreeChartInstance(chart, file, chartId, "Chart: " + chartConfiguration.getName(),
                                       width, height, url);
    } catch (Throwable e) {
        logger.error("Chart exception", e);
        return forwardToPageActionError(e);
    }

    return new ForwardResolution("/m/chart/jfreechart/display.jsp");
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:37,代码来源:JFreeChartAction.java

示例8: forgotPassword2

import net.sourceforge.stripes.util.UrlBuilder; //导入方法依赖的package包/类
public Resolution forgotPassword2() {
    Subject subject = SecurityUtils.getSubject();
    if (subject.isAuthenticated()) {
        logger.debug("Already logged in");
        return redirectToReturnUrl();
    }

    PortofinoRealm portofinoRealm = ShiroUtils.getPortofinoRealm();
    try {
        Serializable user = portofinoRealm.getUserByEmail(email);
        if(user != null) {
            String token = portofinoRealm.generateOneTimeToken(user);
            HttpServletRequest req = context.getRequest();
            String url = req.getRequestURL().toString();
            UrlBuilder urlBuilder = new UrlBuilder(Locale.getDefault(), url, true);
            urlBuilder.setEvent("resetPassword");
            urlBuilder.addParameter("token", token);

            String siteUrl = ServletUtils.getApplicationBaseUrl(req);
            String changePasswordLink = urlBuilder.toString();

            String body = getResetPasswordEmailBody(siteUrl, changePasswordLink);

            String from = portofinoConfiguration.getString(
                    PortofinoProperties.MAIL_FROM, "[email protected]");
            sendForgotPasswordEmail(
                    from, email, ElementsThreadLocals.getText("user.passwordReset.emailSubject"), body);
        }

        SessionMessages.addInfoMessage(ElementsThreadLocals.getText("check.your.mailbox.and.follow.the.instructions"));
    } catch (Exception e) {
        logger.error("Error during password reset", e);
        SessionMessages.addErrorMessage(ElementsThreadLocals.getText("password.reset.failed"));
    }
    return new RedirectResolution(context.getActionPath());
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:37,代码来源:LoginAction.java

示例9: getBlobDownloadUrl

import net.sourceforge.stripes.util.UrlBuilder; //导入方法依赖的package包/类
public String getBlobDownloadUrl(FileBlobField field) {
    UrlBuilder urlBuilder = new UrlBuilder(
            Locale.getDefault(), Util.getAbsoluteUrl(context.getActionPath()), false)
            .addParameter("downloadBlob","")
            .addParameter("propertyName", field.getPropertyAccessor().getName())
            .addParameter("code", field.getValue().getCode());
    return urlBuilder.toString();
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:9,代码来源:AbstractCrudAction.java

示例10: execute

import net.sourceforge.stripes.util.UrlBuilder; //导入方法依赖的package包/类
@DefaultHandler
public Resolution execute() {
	before();
	if (chartConfiguration == null) {
		return forwardToPageActionNotConfigured();
	}

	try {
		// Run/generate the chart
		try {
			Thread.currentThread().setContextClassLoader(Class.class.getClassLoader());
			generateChart();
		} finally {
			Thread.currentThread().setContextClassLoader(ChartAction.class.getClassLoader());
		}

		chartId = RandomUtil.createRandomId();

		String actionurl = context.getActionPath();
		UrlBuilder chartResolution = new UrlBuilder(context.getLocale(), actionurl, false).addParameter("chartId",
				chartId).addParameter("chart", "");
		String url = context.getRequest().getContextPath() + chartResolution.toString();

		file = RandomUtil.getTempCodeFile(CHART_FILENAME_FORMAT, chartId);

		String t_width = context.getRequest().getParameter("width");
		String t_height = context.getRequest().getParameter("height");
		int w = width;
		int h = height;
		if (StringUtils.isNotBlank(t_width)) {
			w = Integer.parseInt(t_width);
		}
		if (StringUtils.isNotBlank(t_height)) {
			h = Integer.parseInt(t_height);
		}

		// if (chartConfiguration.getType().equals(ChartConfiguration.Type.BAR3D_LARGE.name())) {
		// w = 1000;
		// h = 400;
		// }
		jfreeChartInstance = new JFreeChartInstance(chart, file, chartId, "alt", // TODO
				w, h, url);

	} catch (Throwable e) {
		logger.error("Chart exception", e);
		return forwardToPageActionError(e);
	}
	after();
	return forwardTo("/m/chart/chart.jsp");
}
 
开发者ID:hongliangpan,项目名称:manydesigns.cn,代码行数:51,代码来源:ChartAction.java


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