简体   繁体   English

是否有可能在任何拦截器中获取任何文本字段的标签?

[英]Is it possible to get label of any text field inside any interceptor?

I have made a custom interceptor to display the error messages in my own format. 我已经制作了一个自定义拦截器,以我自己的格式显示错误消息。 It is successful to an extent. 它在一定程度上是成功的。

But i would like to know can we get label of any textfield directly from invocation object? 但是我想知道我们可以直接从调用对象中获取任何文本字段的标签吗?

Thanks in advance 提前致谢

If your field labels are localized, then yes, you can get the label text. 如果您的字段标签已本地化,则可以,您可以获得标签文本。 Otherwise, no, since they would just be a string literal in the JSP. 否则,否,因为它们只是JSP中的字符串文字。

Assuming you have a localized property: field.firstName = First Name 假设您具有本地化的属性:field.firstName =名字

You can get that from your interceptor using: 您可以使用以下方法从拦截器中获取:

LocalizedTextUtil.findDefaultText(
    "field.firstName", 
    invocation.getInvocationContext().getLocale()
);

However, if you provide more details on what you are trying to do, we may be able to offer better solutions. 但是,如果您提供有关您要做什么的更多详细信息,我们可能会提供更好的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM