为什么有时在用户界面中使用jsp而不是html? [英] why sometimes jsp is used instead of html for user interface?

查看:101
本文介绍了为什么有时在用户界面中使用jsp而不是html?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在开发Spring MVC的项目.该项目在前端用户界面中使用jsp而不是html.您能告诉我为什么要使用jsp而不是HTML吗.在Spring MVC中使用.jsp文件而不是.html有什么特殊用途.我不能使用html和Javascript实现相同的功能吗?
我了解这是一个基本问题,但是我没有任何Web开发经验,我刚开始在一家公司工作,他们希望我从事这个工作.我试图寻找比较,但是在线上的jsp和servlet之间有很多比较,但是我找不到任何能说明为什么使用jsp而不是HTML页面的东西.这对您来说可能很明显,但对我而言却不是.任何提示,链接,描述都值得赞赏.

I have a project that I am working on Spring MVC. The project uses jsp instead of html in my view for the front end UI. Can you please tell me why jsp is being used and not HTML. Is there any special purpose for using .jsp files instead of .html in Spring MVC. Can't I use html and Javascript to achieve the same functionality?
I understand this is a basic question but I dont have any experience in web development, I have just started working in a company and they want me to work on this. I have tried looking for comparisons, but there are a lot of comparison between jsp and servlets online but I cant find anything which tells why jsp is used instead of HTML pages. This might be very obvious to you but its not to me. Any hints, links, description is appreciated.

推荐答案

根据我的以下经验,通常使用jsp或更高版本来渲染视图的模板语言的原因.

From my experience below are the reason of using jsp or more in general a template language for rendering view.

  • HTML无法读取请求数据,因为它实际上不知道什么是请求/会话数据,并且实际上与它无关.另一方面,jsp知道请求,响应,会话等.

  • HTML can not read request data as it actually don't know what is request / session data and it has nothing to do with it actually. On the other hand, jsp knows request, response, session etc.

当您需要动态生成内容时,可以使用循环和其他可用的逻辑内容,但是您将如何在html中做到这一点?您的答案可能是使用javascript,但这会带来更多问题.

when you need to generate your content dynamically you may use loops and other logical stuff available but how will you do that in html? Your answer could be using javascript but it would be more problematic.

HTML是静态类型的,并在浏览器(即客户端)处进行解析,因此将在客户端进行评估,从而公开您的页面并允许客户端进行多种操作.但是JSP是服务器端的,因此更加安全,因为客户端只能最后访问html.

HTML is statically typed and is parsed at browser i.e. client side and hence would be evaluated at client side which exposes your page and would allow client to do several manipulations. But JSPs are server side and hence are more secure and safe as client can only access html in last.

最后但并非最不重要的一点是,Java知道JSP,但是不了解html,因此对于使用JSP的开发人员来说更好,因为他们可以轻松地执行UI开发人员无法做到的良好操作.

Last but not least Java knows JSP but not html and hence for developers using JSP is better as they easily do good manipulations which a UI dev can't do .

希望有帮助!

这篇关于为什么有时在用户界面中使用jsp而不是html?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆