Java Code Examples for org.springframework.web.util.WebUtils#DEFAULT_CHARACTER_ENCODING

The following examples show how to use org.springframework.web.util.WebUtils#DEFAULT_CHARACTER_ENCODING . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoginController.java    From JDeSurvey with GNU Affero General Public License v3.0 6 votes vote down vote up
String encodeUrlPathSegment(String pathSegment, HttpServletRequest httpServletRequest) {
	log.info("encodeUrlPathSegment()");
	try{
		String enc = httpServletRequest.getCharacterEncoding();
		if (enc == null) {
			enc = WebUtils.DEFAULT_CHARACTER_ENCODING;
		}
		try {
			pathSegment = UriUtils.encodePathSegment(pathSegment, enc);
		} catch (UnsupportedEncodingException uee) {log.error(uee);}
		return pathSegment;
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		throw (new RuntimeException(e));
	}
}
 
Example 2
Source File: VelocityTemplateController.java    From JDeSurvey with GNU Affero General Public License v3.0 6 votes vote down vote up
String encodeUrlPathSegment(String pathSegment, HttpServletRequest httpServletRequest) {
	log.info("encodeUrlPathSegment()");
	try{
		String enc = httpServletRequest.getCharacterEncoding();
		if (enc == null) {
			enc = WebUtils.DEFAULT_CHARACTER_ENCODING;
		}
		try {
			pathSegment = UriUtils.encodePathSegment(pathSegment, enc);
		} catch (UnsupportedEncodingException uee) {log.error(uee);}
		return pathSegment;
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		throw (new RuntimeException(e));
	}
}
 
Example 3
Source File: QuestionColumnLabelController.java    From JDeSurvey with GNU Affero General Public License v3.0 6 votes vote down vote up
String encodeUrlPathSegment(String pathSegment, HttpServletRequest httpServletRequest) {
	log.info("encodeUrlPathSegment()");
	try{
		String enc = httpServletRequest.getCharacterEncoding();
		if (enc == null) {
			enc = WebUtils.DEFAULT_CHARACTER_ENCODING;
		}
		try {
			pathSegment = UriUtils.encodePathSegment(pathSegment, enc);
		} catch (UnsupportedEncodingException uee) {log.error(uee);}
		return pathSegment;
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		throw (new RuntimeException(e));
	}
}
 
Example 4
Source File: AuthorityController.java    From JDeSurvey with GNU Affero General Public License v3.0 6 votes vote down vote up
String encodeUrlPathSegment(String pathSegment, HttpServletRequest httpServletRequest) {
	log.info("encodeUrlPathSegment()");
	try{
		String enc = httpServletRequest.getCharacterEncoding();
		if (enc == null) {
			enc = WebUtils.DEFAULT_CHARACTER_ENCODING;
		}
		try {
			pathSegment = UriUtils.encodePathSegment(pathSegment, enc);
		} catch (UnsupportedEncodingException uee) {log.error(uee);}
		return pathSegment;
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		throw (new RuntimeException(e));
	}
}
 
Example 5
Source File: UserController.java    From JDeSurvey with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Helper method that encodes a string
 * @param pathSegment
 * @param httpServletRequest
 * @return
 */
String encodeUrlPathSegment(String pathSegment, HttpServletRequest httpServletRequest) {
	log.info("encodeUrlPathSegment()");
	try{
		String enc = httpServletRequest.getCharacterEncoding();
		if (enc == null) {
			enc = WebUtils.DEFAULT_CHARACTER_ENCODING;
		}
		try {
			pathSegment = UriUtils.encodePathSegment(pathSegment, enc);
		} catch (UnsupportedEncodingException uee) {log.error(uee);}
		return pathSegment;
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		throw (new RuntimeException(e));
	}
}
 
Example 6
Source File: GroupController.java    From JDeSurvey with GNU Affero General Public License v3.0 6 votes vote down vote up
String encodeUrlPathSegment(String pathSegment, HttpServletRequest httpServletRequest) {
	log.info("encodeUrlPathSegment()");
	try{
		String enc = httpServletRequest.getCharacterEncoding();
		if (enc == null) {
			enc = WebUtils.DEFAULT_CHARACTER_ENCODING;
		}
		try {
			pathSegment = UriUtils.encodePathSegment(pathSegment, enc);
		} catch (UnsupportedEncodingException uee) {log.error(uee);}
		return pathSegment;
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		throw (new RuntimeException(e));
	}
}
 
Example 7
Source File: SectorsController.java    From JDeSurvey with GNU Affero General Public License v3.0 6 votes vote down vote up
String encodeUrlPathSegment(String pathSegment, HttpServletRequest httpServletRequest) {
	log.info("encodeUrlPathSegment()");
	try{
		String enc = httpServletRequest.getCharacterEncoding();
		if (enc == null) {
			enc = WebUtils.DEFAULT_CHARACTER_ENCODING;
		}
		try {
			pathSegment = UriUtils.encodePathSegment(pathSegment, enc);
		} catch (UnsupportedEncodingException uee) {log.error(uee);}
		return pathSegment;
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		throw (new RuntimeException(e));
	}
}
 
Example 8
Source File: DepartmentController.java    From JDeSurvey with GNU Affero General Public License v3.0 6 votes vote down vote up
String encodeUrlPathSegment(String pathSegment, HttpServletRequest httpServletRequest) {
	log.info("encodeUrlPathSegment()");
	try{
		String enc = httpServletRequest.getCharacterEncoding();
		if (enc == null) {
			enc = WebUtils.DEFAULT_CHARACTER_ENCODING;
		}
		try {
			pathSegment = UriUtils.encodePathSegment(pathSegment, enc);
		} catch (UnsupportedEncodingException uee) {log.error(uee);}
		return pathSegment;
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		throw (new RuntimeException(e));
	}
}
 
Example 9
Source File: RegularExpressionController.java    From JDeSurvey with GNU Affero General Public License v3.0 6 votes vote down vote up
String encodeUrlPathSegment(String pathSegment, HttpServletRequest httpServletRequest) {
	log.info("encodeUrlPathSegment()");
	try{
		String enc = httpServletRequest.getCharacterEncoding();
		if (enc == null) {
			enc = WebUtils.DEFAULT_CHARACTER_ENCODING;
		}
		try {
			pathSegment = UriUtils.encodePathSegment(pathSegment, enc);
		} catch (UnsupportedEncodingException uee) {log.error(uee);}
		return pathSegment;
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		throw (new RuntimeException(e));
	}
}
 
Example 10
Source File: GlobalSettingsController.java    From JDeSurvey with GNU Affero General Public License v3.0 6 votes vote down vote up
String encodeUrlPathSegment(String pathSegment, HttpServletRequest httpServletRequest) {
	log.info("encodeUrlPathSegment()");
	try{
		String enc = httpServletRequest.getCharacterEncoding();
		if (enc == null) {
			enc = WebUtils.DEFAULT_CHARACTER_ENCODING;
		}
		try {
			pathSegment = UriUtils.encodePathSegment(pathSegment, enc);
		} catch (UnsupportedEncodingException uee) {log.error(uee);}
		return pathSegment;
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		throw (new RuntimeException(e));
	}
}
 
Example 11
Source File: QuestionRowLabelController.java    From JDeSurvey with GNU Affero General Public License v3.0 6 votes vote down vote up
String encodeUrlPathSegment(String pathSegment, HttpServletRequest httpServletRequest) {
	log.info("encodeUrlPathSegment()");
	try{
		String enc = httpServletRequest.getCharacterEncoding();
		if (enc == null) {
			enc = WebUtils.DEFAULT_CHARACTER_ENCODING;
		}
		try {
			pathSegment = UriUtils.encodePathSegment(pathSegment, enc);
		} catch (UnsupportedEncodingException uee) {log.error(uee);}
		return pathSegment;
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		throw (new RuntimeException(e));
	}
}
 
Example 12
Source File: InvitationController.java    From JDeSurvey with GNU Affero General Public License v3.0 6 votes vote down vote up
String encodeUrlPathSegment(String pathSegment, HttpServletRequest httpServletRequest) {
	log.info("encodeUrlPathSegment()");
	try{
		String enc = httpServletRequest.getCharacterEncoding();
		if (enc == null) {
			enc = WebUtils.DEFAULT_CHARACTER_ENCODING;
		}
		try {
			pathSegment = UriUtils.encodePathSegment(pathSegment, enc);
		} catch (UnsupportedEncodingException uee) {log.error(uee);}
		return pathSegment;
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		throw (new RuntimeException(e));
	}
}
 
Example 13
Source File: DataSetController.java    From JDeSurvey with GNU Affero General Public License v3.0 6 votes vote down vote up
String encodeUrlPathSegment(String pathSegment, HttpServletRequest httpServletRequest) {
	log.info("encodeUrlPathSegment()");
	try{
		String enc = httpServletRequest.getCharacterEncoding();
		if (enc == null) {
			enc = WebUtils.DEFAULT_CHARACTER_ENCODING;
		}
		try {
			pathSegment = UriUtils.encodePathSegment(pathSegment, enc);
		} catch (UnsupportedEncodingException uee) {log.error(uee);}
		return pathSegment;
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		throw (new RuntimeException(e));
	}
}
 
Example 14
Source File: SurveyDefinitionPageController.java    From JDeSurvey with GNU Affero General Public License v3.0 6 votes vote down vote up
String encodeUrlPathSegment(String pathSegment, HttpServletRequest httpServletRequest) {
	log.info("encodeUrlPathSegment()");
	try{
		String enc = httpServletRequest.getCharacterEncoding();
		if (enc == null) {
			enc = WebUtils.DEFAULT_CHARACTER_ENCODING;
		}
		try {
			pathSegment = UriUtils.encodePathSegment(pathSegment, enc);
		} catch (UnsupportedEncodingException uee) {log.error(uee);}
		return pathSegment;
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		throw (new RuntimeException(e));
	}
}
 
Example 15
Source File: SurveyDefinitionController.java    From JDeSurvey with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Encodes a string path suing the  httpServletRequest Character Encoding
 * @param pathSegment
 * @param httpServletRequest
 * @return
 */
String encodeUrlPathSegment(String pathSegment, HttpServletRequest httpServletRequest) {
	log.info("encodeUrlPathSegment()");
	try{
		String enc = httpServletRequest.getCharacterEncoding();
		if (enc == null) {
			enc = WebUtils.DEFAULT_CHARACTER_ENCODING;
		}
		try {
			pathSegment = UriUtils.encodePathSegment(pathSegment, enc);
		} catch (UnsupportedEncodingException uee) {log.error(uee);}
		return pathSegment;
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		throw (new RuntimeException(e));
	}
}
 
Example 16
Source File: RedirectView.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Create the target URL by checking if the redirect string is a URI template first,
 * expanding it with the given model, and then optionally appending simple type model
 * attributes as query String parameters.
 */
protected final String createTargetUrl(Map<String, Object> model, HttpServletRequest request)
		throws UnsupportedEncodingException {

	// Prepare target URL.
	StringBuilder targetUrl = new StringBuilder();
	String url = getUrl();
	Assert.state(url != null, "'url' not set");

	if (this.contextRelative && getUrl().startsWith("/")) {
		// Do not apply context path to relative URLs.
		targetUrl.append(getContextPath(request));
	}
	targetUrl.append(getUrl());

	String enc = this.encodingScheme;
	if (enc == null) {
		enc = request.getCharacterEncoding();
	}
	if (enc == null) {
		enc = WebUtils.DEFAULT_CHARACTER_ENCODING;
	}

	if (this.expandUriTemplateVariables && StringUtils.hasText(targetUrl)) {
		Map<String, String> variables = getCurrentRequestUriVariables(request);
		targetUrl = replaceUriTemplateVariables(targetUrl.toString(), model, variables, enc);
	}
	if (isPropagateQueryProperties()) {
		appendCurrentQueryParams(targetUrl, request);
	}
	if (this.exposeModelAttributes) {
		appendQueryProperties(targetUrl, model, enc);
	}

	return targetUrl.toString();
}
 
Example 17
Source File: CommonsFileUploadSupport.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
protected String getDefaultEncoding() {
	String encoding = getFileUpload().getHeaderEncoding();
	if (encoding == null) {
		encoding = WebUtils.DEFAULT_CHARACTER_ENCODING;
	}
	return encoding;
}
 
Example 18
Source File: CommonsFileUploadSupport.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Determine the default encoding to use for parsing requests.
 * @see #setDefaultEncoding
 */
protected String getDefaultEncoding() {
	String encoding = getFileUpload().getHeaderEncoding();
	if (encoding == null) {
		encoding = WebUtils.DEFAULT_CHARACTER_ENCODING;
	}
	return encoding;
}
 
Example 19
Source File: RedirectView.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create the target URL by checking if the redirect string is a URI template first,
 * expanding it with the given model, and then optionally appending simple type model
 * attributes as query String parameters.
 */
protected final String createTargetUrl(Map<String, Object> model, HttpServletRequest request)
		throws UnsupportedEncodingException {

	// Prepare target URL.
	StringBuilder targetUrl = new StringBuilder();
	if (this.contextRelative && getUrl().startsWith("/")) {
		// Do not apply context path to relative URLs.
		targetUrl.append(request.getContextPath());
	}
	targetUrl.append(getUrl());

	String enc = this.encodingScheme;
	if (enc == null) {
		enc = request.getCharacterEncoding();
	}
	if (enc == null) {
		enc = WebUtils.DEFAULT_CHARACTER_ENCODING;
	}

	if (this.expandUriTemplateVariables && StringUtils.hasText(targetUrl)) {
		Map<String, String> variables = getCurrentRequestUriVariables(request);
		targetUrl = replaceUriTemplateVariables(targetUrl.toString(), model, variables, enc);
	}
	if (isPropagateQueryProperties()) {
	 	appendCurrentQueryParams(targetUrl, request);
	}
	if (this.exposeModelAttributes) {
		appendQueryProperties(targetUrl, model, enc);
	}

	return targetUrl.toString();
}
 
Example 20
Source File: CommonsFileUploadSupport.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Determine the default encoding to use for parsing requests.
 * @see #setDefaultEncoding
 */
protected String getDefaultEncoding() {
	String encoding = getFileUpload().getHeaderEncoding();
	if (encoding == null) {
		encoding = WebUtils.DEFAULT_CHARACTER_ENCODING;
	}
	return encoding;
}