问题
Is there any tool to do for JSP files what checkstyle does for Java files? The ideal would be to include JSP checking on checkstyle, but as far as I can see, this isn't possible.
I would like for example to check JSP files for :
- Indentation style
- Right placements of certain constructs
- Tab / space check
- Check for use of scriplets
Thanks Emerson
回答1:
Yes, there is something similar (but not for exactly those checks): You can use IntelliJ IDEA's "Inspection" functionality to inspect JSPs for various problems, and those inspections can be run from the command line too (use inspect.bat in IntelliJ's /bin directory).
For this you will need to create a "profile" to include only the desired JSP inspections, test it from the IDE (Analyze/Inspect Code), and if they're OK, run them from the command line too (and e.g. call them from your build tool).
Based on those existing JSP inspections, than you could write other inspections too (but this require a little more skill since there's no good documentation for this - just the source code of IntelliJ plug-ins and the support forums)
回答2:
PMD supports checking of JSP files as well. There are very few rules though. I haven't used it extensively. Feel free to try it out.
来源:https://stackoverflow.com/questions/3283078/checkstyle-equivalent-for-jsps