简体   繁体   中英

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.

Assuming you have a localized property: field.firstName = First Name

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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