开发者

Automatically tidy up JSP/JSF files

开发者 https://www.devze.com 2022-12-24 16:50 出处:网络
I am working on a webapplication and I do most of the XHTML stuff in an editor. Every once in a while I froget to close a tag or mess up the nesting (we all get distracted sometimes ;-)).

I am working on a webapplication and I do most of the XHTML stuff in an editor. Every once in a while I froget to close a tag or mess up the nesting (we all get distracted sometimes ;-)).

So I commpile, package and run my webapp (using maven mvn clean package jetty:run-war only to notice that displaying the view (where I messed up the jsp) fails with an exception 开发者_StackOverflow社区while trying to render.

So I wondered: Is there some tool that I can include into my build-cycle that automatically catches and rectifies those careless mistakes?


There is the Maven CheckStyle plugin that looks at certain style rules in Java and other languages. It is customisable so you can add other rules. I can't say for sure that it will catch unclosed tags but this may be the place to start.

Using an IDE like Ecplipse or Netbeans will highlight any invalid code also. So you can actually see a red mark on the page as you type. That may be even more effective.


Maybe a regular xml checker would do the trick. After all a JSP file is if properly written valid xml.

0

精彩评论

暂无评论...
验证码 换一张
取 消