问题描述:

I have a Spring Expression Language (SpEL) expression within a Thymeleaf attribute. It's getting a little long, and part of it may not be clear to other developers, so I want to include a comment within it.

I'm looking to do something like:

T(example.long.package.MyClass).someMethod("abc" /* Explain why value is "abc" here */ )

Except that the /*...*/ syntax doesn't work, and the expression is of course more complicated. This is just an example; I'm looking for a general way of having comments within complicated SpEL expressions. I don't see any references to commenting within the Spring documentation chapter on SpEL.

I can work around it for now by having a Thymeleaf/HTML comment near the expression, I just would like to be able to have comments within expressions as well.

网友答案:

I think it's better to include a Javadoc for example.long.package.MyClass.someMethod.
Include comments for business methods into the view is not good practice (IMHO)

相关阅读:
Top