private void setDefaultConfiguredEncoding(
     HttpServletRequest request, GrailsContentBufferingResponse contentBufferingResponse) {
   UrlPathHelper urlHelper = new UrlPathHelper();
   String requestURI = urlHelper.getOriginatingRequestUri(request);
   // static content?
   if (requestURI.endsWith(HTML_EXT)) {
     contentBufferingResponse.setContentType("text/html;charset=" + defaultEncoding);
   }
 }
 /**
  * 获得当的访问路径
  *
  * <p>HttpServletRequest.getRequestURL+"?"+HttpServletRequest.getQueryString
  *
  * @param request
  * @return
  */
 public static String getLocation(HttpServletRequest request) {
   UrlPathHelper helper = new UrlPathHelper();
   StringBuffer buff = request.getRequestURL();
   String uri = request.getRequestURI();
   String origUri = helper.getOriginatingRequestUri(request);
   buff.replace(buff.length() - uri.length(), buff.length(), origUri);
   String queryString = helper.getOriginatingQueryString(request);
   if (queryString != null) {
     buff.append("?").append(queryString);
   }
   return buff.toString();
 }
Beispiel #3
0
  private void prepareLinkPrefix(HttpServletRequest request) {
    StringBuffer url = new StringBuffer(urlPathHelper.getOriginatingRequestUri(request));

    url.append('?');
    if (copyParameters) {
      String query = urlPathHelper.getOriginatingQueryString(request);
      if (query != null) {
        int i = query.indexOf(pageParam);
        if (i != -1) {
          url.append(query.substring(0, i));
        } else {
          url.append(query).append('&');
        }
      }
    }
    url.append(pageParam);
    url.append('=');
    linkPrefix = url.toString();
  }