Are JSP scriptlets an antipattern? [closed]

人走茶凉 提交于 2021-01-28 02:35:38

问题


I hope you understand the question. What do you think? If I post some code here with scriptlet I'm convinced that you're going to tell me not to use scriptlet whatsoever. Right?


回答1:


I think yes, it should be avoided for a couple of reasons. At first I really don't appreciate salad in my code :) JSP is intended for marking up the things, not for logic in the representation layer. Its just not readable.

At second, when I've started to learn JSP I was told that those who developed JSP thought that in ideal world those who really create jsp pages shouldn't be java programmers. If you need something that should be done by logic in JSP (conditions/loops and so forth) java programmer will better create tags/ tag files in newer jsp versions.

Hope this helps




回答2:


No , but understanding will be tough and there is no performance related problem

Check this article for more information: Scriptless JSP Pages: The Front Man




回答3:


No logic in JSP. Just plain working with beans. :) So IMO scriplets wouldn't be a good solution. UI must be UI, but not something very heavy.



来源:https://stackoverflow.com/questions/13081818/are-jsp-scriptlets-an-antipattern

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!