自动整理JSP/JSF文件
我正在开发一个 Web 应用程序,并且在编辑器中完成大部分 XHTML 工作。 每隔一段时间,我就会忘记关闭标签或弄乱嵌套(有时我们都会分心;-))。
因此,我编译、打包并运行我的 web 应用程序(使用 maven mvn clean package jetty:run-war
只注意到显示视图(我搞乱了 jsp 的地方)在尝试渲染时失败并出现异常所以
我想知道: 是否有一些工具可以包含在我的构建周期中,自动捕获并纠正那些粗心的错误?
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 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有 Maven CheckStyle 插件,它查看 Java 中的某些样式规则,其他语言。它是可定制的,因此您可以添加其他规则。我不能肯定地说它会捕获未封闭的标签,但这可能是开始的地方。
使用 Ecplipse 或 Netbeans 等 IDE 也会突出显示任何无效代码。因此,当您键入时,您实际上可以在页面上看到红色标记。这可能会更有效。
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.
也许常规的 xml 检查器就可以解决问题。毕竟,如果正确编写,JSP 文件就是有效的 xml。
Maybe a regular xml checker would do the trick. After all a JSP file is if properly written valid xml.