Java Code Examples for org.springframework.web.servlet.support.RequestContext#getMessage()

The following examples show how to use org.springframework.web.servlet.support.RequestContext#getMessage() . 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: I18nFunction.java    From java-platform with Apache License 2.0 5 votes vote down vote up
@Override
public Object call(Object[] paras, Context ctx) {

	RequestContext requestContext = (RequestContext) ctx
			.getGlobal(AbstractTemplateView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE);

	Assert.notNull(requestContext);
	Assert.notNull(paras);
	Assert.isTrue(paras.length > 0);

	String code = (String) paras[0];
	Object[] args = paras.length > 1 ? Arrays.copyOfRange(paras, 1, paras.length) : null;

	return requestContext.getMessage(code, args);
}
 
Example 2
Source File: ExceptionManager.java    From BlogSystem with Apache License 2.0 4 votes vote down vote up
public BaseRuntimeException getUnknownBlogException(RequestContext context) {
    return new UnknownBlogException(context.getMessage("blog.unknownBlog"));
}
 
Example 3
Source File: ExceptionManager.java    From BlogSystem with Apache License 2.0 4 votes vote down vote up
public BaseRuntimeException getBlogIllegalException(RequestContext context) {
    return new BlogContentIllegalException(context.getMessage("blog.illegal"));
}
 
Example 4
Source File: ExceptionManager.java    From BlogSystem with Apache License 2.0 4 votes vote down vote up
public BaseRuntimeException getBloggerNotLoggedInException(RequestContext context) {
    return new BloggerNotLoggedInException(context.getMessage("blogger.notLoggedIn"));
}
 
Example 5
Source File: ApiResponse.java    From j360-dubbo-app-all with Apache License 2.0 4 votes vote down vote up
private static String getMessage(String code,HttpServletRequest request){
    RequestContext requestContext = new RequestContext(request);
    return requestContext.getMessage(String.valueOf(code));
}
 
Example 6
Source File: ExceptionManager.java    From BlogSystem with Apache License 2.0 4 votes vote down vote up
public BaseRuntimeException getUnauthorizedException(RequestContext context) {
    return new UnauthorizedException(context.getMessage("common.unauthorized"));
}
 
Example 7
Source File: ExceptionManager.java    From BlogSystem with Apache License 2.0 4 votes vote down vote up
public BaseRuntimeException getParameterTypeMismatchException(RequestContext context, Throwable e) {
    return new ParameterTypeMismatchException(context.getMessage("common.parameterTypeMismatch"), e);
}
 
Example 8
Source File: ExceptionManager.java    From BlogSystem with Apache License 2.0 4 votes vote down vote up
public BaseRuntimeException getUnknownLinkException(RequestContext context) {
    return new UnknownLinkException(context.getMessage("common.unknownLink"));
}
 
Example 9
Source File: ExceptionManager.java    From BlogSystem with Apache License 2.0 4 votes vote down vote up
public BaseRuntimeException getPictureFormatErrorException(RequestContext context) {
    return new PictureFormatErrorException(context.getMessage("common.pictureFormatError"));
}
 
Example 10
Source File: ExceptionManager.java    From BlogSystem with Apache License 2.0 4 votes vote down vote up
public BaseRuntimeException getMissingRequestParameterException(RequestContext context, Throwable e) {
    return new MissingRequestParameterException(context.getMessage("common.missingRequestParameter"), e);
}
 
Example 11
Source File: ExceptionManager.java    From BlogSystem with Apache License 2.0 4 votes vote down vote up
public BaseRuntimeException getUnknownException(RequestContext context, Throwable e) {
    return new UnknownException(context.getMessage("common.UnknownError"), e);
}
 
Example 12
Source File: ExceptionManager.java    From BlogSystem with Apache License 2.0 4 votes vote down vote up
public BaseRuntimeException getUnspecifiedOperationException(RequestContext context) {
    return new UnspecifiedOperationException(context.getMessage("common.unspecifiedOperation"));
}
 
Example 13
Source File: ExceptionManager.java    From BlogSystem with Apache License 2.0 4 votes vote down vote up
public BaseRuntimeException getOperateFailException(RequestContext context) {
    return new OperateFailException(context.getMessage("common.operateFail"));
}
 
Example 14
Source File: ExceptionManager.java    From BlogSystem with Apache License 2.0 4 votes vote down vote up
public BaseRuntimeException getParameterIllegalException(RequestContext context) {
    return new ParameterIllegalException(context.getMessage("common.parameterIllegal"));
}
 
Example 15
Source File: ExceptionManager.java    From BlogSystem with Apache License 2.0 4 votes vote down vote up
public BaseRuntimeException getBlogSortOrderUndefinedException(RequestContext context) {
    return new BlogSortOrderUndefinedException(context.getMessage("blog.blogSortOrderUndefined"));
}
 
Example 16
Source File: ExceptionManager.java    From BlogSystem with Apache License 2.0 4 votes vote down vote up
public BaseRuntimeException getBlogSortRuleUndefinedException(RequestContext context) {
    return new BlogSortRuleUndefinedException(context.getMessage("blog.blogSortRuleUndefined"));
}
 
Example 17
Source File: ExceptionManager.java    From BlogSystem with Apache License 2.0 4 votes vote down vote up
public BaseRuntimeException getParameterStringSplitException(RequestContext context) {
    return new ParameterStringSplitException(context.getMessage("common.parameterStringSplitIllegal"));
}
 
Example 18
Source File: ExceptionManager.java    From BlogSystem with Apache License 2.0 4 votes vote down vote up
public BaseRuntimeException getUnknownBloggerException(RequestContext context) {
    return new UnknownBloggerException(context.getMessage("blogger.unknownBlogger"));
}
 
Example 19
Source File: ExceptionManager.java    From BlogSystem with Apache License 2.0 4 votes vote down vote up
public BaseRuntimeException getEmptyResultException(RequestContext context) {
    return new EmptyResultException(context.getMessage("common.emptyResult"));
}
 
Example 20
Source File: MessageManager.java    From BlogSystem with Apache License 2.0 2 votes vote down vote up
/**
 * 获得登录失败说明信息
 *
 * @param passwordIncorrect 密码是否错误:true 表明用户名正确,但密码错误,false 表明用户名(错误)不存在
 * @return 国际化了的说明信息
 */
public String getLoginFailMessage(RequestContext context, boolean passwordIncorrect) {
    return context.getMessage(passwordIncorrect ? "blogger.passwordIncorrect" : "blogger.unknownAccount");
}