有什么办法可以减少JSP页面的冗长吗
在 RESTful Java/ExtJS 应用程序上工作了三年之后,我接管了 Java/JSP 应用程序的开发。
对于 Java Struts 新手,我发现在 JSP 页面中使用 struts 标签非常冗长,例如,
<input type="button" value='<bean:message key="button.addDoc"/>' />
当然每个页面中大约有 1700 个消息标签,看起来像 $m("button.addDoc")就足够了。是否有某种方法可以缩短 bean:message 元素以减少噪音,或者这只是 Java 的方式?
After three years on a RESTful Java/ExtJS application, I have taken over development of a Java/JSP application.
New to Java Struts, I am finding the use of struts tags in JSP pages to be insanely verbose, e.g.
<input type="button" value='<bean:message key="button.addDoc"/>' />
Of course there are about 1700 message tags in every page, and it would seem that something like $m("button.addDoc") would be quite enough. Is there some way to shorten the bean:message elements to something less noisy, or is this just the Java way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这只是 Struts 方式。这是一个相当传统的 MVC 框架。您可以考虑寻找仅通过 EL 解析属性的不同 MVC 框架,例如 JSF。
例如,
对于那么多的页面/标签来说,只会需要大量的工作。因为这显然是一项任务,所以我只能接受它并为将来保留它以拒绝旧的基于 Struts 的项目。
That's just the Struts way. It's a pretty legacy MVC framework. You could consider to look for a different MVC framework which resolves properties by just EL, for example JSF.
E.g.
It's only going to be a lot of work with that much pages/tags. Since it's apparently an assignment, I'd just live with it and keep it for the future in mind to deny old Struts based projects.