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


Java UrlBuilder.addParameter方法代码示例

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


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

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

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

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

示例4: createParticipantUrl

import net.sourceforge.stripes.util.UrlBuilder; //导入方法依赖的package包/类
/**
 * Create a participant url for the given participant
 * @param p the participant
 * @param baseUrl the base url used to build this url. 
 * @return 
 */
protected String createParticipantUrl(Participant p, String baseUrl){
    StringBuffer sb = new StringBuffer();
    if (baseUrl!=null){
        sb.append(baseUrl);       
    }
    UrlBuilder builder = new UrlBuilder(Locale.ENGLISH, KaratekaPointsActionBean.class, false);
    builder.addParameter("p", p.getId());
    builder.addParameter("code",KaratekaPointsActionBean.generateCode(p, this.getContext()));
    sb.append(builder.toString());
    return sb.toString();
}
 
开发者ID:rbraam,项目名称:vanenapp,代码行数:18,代码来源:OrganizeVanencompetitionActionBean.java

示例5: showOpenIDForm

import net.sourceforge.stripes.util.UrlBuilder; //导入方法依赖的package包/类
public Resolution showOpenIDForm()
        throws ConsumerException, MessageException, DiscoveryException, MalformedURLException {
    ConsumerManager manager = new ConsumerManager();

    // perform discovery on the user-supplied identifier
    List discoveries = manager.discover(openIdUrl);

    // attempt to associate with the OpenID provider
    // and retrieve one service endpoint for authentication
    DiscoveryInformation discovered = manager.associate(discoveries);

    UrlBuilder urlBuilder = new UrlBuilder(context.getLocale(), context.getActionPath(), false);
    urlBuilder.setEvent("handleOpenIDLogin");
    urlBuilder.addParameter("returnUrl", returnUrl);
    urlBuilder.addParameter("cancelReturnUrl", cancelReturnUrl);

    URL url = new URL(context.getRequest().getRequestURL().toString());
    String port = url.getPort() > 0 ? ":" + url.getPort() : "";
    String baseUrl = url.getProtocol() + "://" + url.getHost() + port;
    String urlString = baseUrl + context.getRequest().getContextPath() + urlBuilder;
    // obtain a AuthRequest message to be sent to the OpenID provider
    AuthRequest authReq = manager.authenticate(discovered, urlString, baseUrl);

    // store the discovery information in the user's session for later use
    // leave out for stateless operation / if there is no session
    HttpSession session = context.getRequest().getSession();
    session.setAttribute(OPENID_DISCOVERED, discovered);
    session.setAttribute(OPENID_CONSUMER_MANAGER, manager);

    String destinationUrl = authReq.getDestinationUrl(true);

    if(destinationUrl.length() > 2000) {
        if(authReq.isVersion2()) {
            openIdDestinationUrl = authReq.getDestinationUrl(false);
            openIdParameterMap = authReq.getParameterMap();
            return new ForwardResolution("/m/openid/pageactions/openid/openIDFormRedirect.jsp");
        } else {
            SessionMessages.addErrorMessage("Cannot login, payload too big and OpenID version 2 not supported.");
            return new ForwardResolution(getLoginPage());
        }
    } else {
        return new RedirectResolution(destinationUrl, false);
    }
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:45,代码来源:OpenIdLoginAction.java


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