Example usage for org.springframework.web.util UriUtils encodePath

List of usage examples for org.springframework.web.util UriUtils encodePath

Introduction

In this page you can find the example usage for org.springframework.web.util UriUtils encodePath.

Prototype

public static String encodePath(String path, Charset charset) 

Source Link

Document

Encode the given URI path with the given encoding.

Usage

From source file:springfox.documentation.spring.web.ControllerNamingUtils.java

public static String encode(String path) {
    try {//from  w  ww.ja v a 2 s. c om
        path = UriUtils.encodePath(path, ISO_8859_1);
    } catch (UnsupportedEncodingException e) {
        log.error("Could not encode:" + path, e);
    }
    return path;
}

From source file:org.cleverbus.admin.web.log.LogController.java

@RequestMapping("/")
public String getLogSearch(@RequestParam(value = "fromDate", required = false) DateTime fromDate,
        @RequestParam MultiValueMap<String, String> params, Model model) throws UnsupportedEncodingException {
    if (fromDate != null) {
        params.remove("fromDate");
        // remove empty values:
        for (List<String> valueList : params.values()) {
            ListIterator<String> values = valueList.listIterator();
            while (values.hasNext()) {
                if (!StringUtils.hasText(values.next())) {
                    values.remove();//w  w w.j  av a  2 s  .  c om
                }
            }
        }
        model.mergeAttributes(params);
        return "redirect:"
                + UriUtils.encodePath(LogParserConstants.LOGBACK_ISO8601_FORMAT.print(fromDate), "UTF-8");
    }

    model.addAttribute("fromDate", LogParserConstants.LOGBACK_ISO8601_FORMAT.print(
            DateTime.now().minusHours(2).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0)));

    LogParserConfig logParserConfig = new LogParserConfig();
    logParserConfig.setGroupBy(LogParserConstants.DEFAULT_GROUP_BY_PROPERTY);
    logParserConfig.setGroupLimit(LogParserConstants.DEFAULT_GROUP_SIZE);
    model.addAttribute("config", logParserConfig);

    return "logSearch";
}

From source file:eionet.util.Util.java

/**
 * Encodes URL fragment to UTF-8./*from   ww  w.ja va  2s .  com*/
 *
 * @param value
 *            value to be encoded
 * @return encoded value
 */
public static String encodeURLPath(String value) {
    String retValue = value;
    try {
        retValue = UriUtils.encodePath(value, "utf-8");
    } catch (UnsupportedEncodingException ue) {
        return retValue;
    }

    return retValue;
}