简体   繁体   English

使用JSP MVC的单页应用程序

[英]Single-page application with jsp mvc

I'm pretty new to Angular and jsp and I have a question about general architecture of a single-page system. 我是Angular和jsp的新手,我对单页系统的一般体系结构有疑问。 I understand that jsp mvc has it's own security features that some of course related to conditionally delivering static/dynamic pages to the clients. 我了解到,jsp mvc具有其自身的安全性功能,其中某些功能当然与有条件地向客户端提供静态/动态页面有关。

How can that feature work with Angular? 该功能如何与Angular一起使用? Obviously in a single page application, working with partials, the server does not need to pass pages to the client. 显然,在使用分页的单页面应用程序中,服务器不需要将页面传递给客户端。

My specific question is about the login page. 我的具体问题是关于登录页面。 Do I need to separate my login html from my main 'single-page' index.html with all my routes? 我是否需要使用所有路由将登录html与主“单页” index.html分开? Will I have a 'login.jsp' file which is a stand-alone file handled by jsp and only after login routing to the single-page part of the application? 我是否将有一个“ login.jsp”文件,它是由jsp处理并且仅在登录路由到应用程序的单页部分之后的独立文件?

Thanks!!! 谢谢!!!

Regarding the login part: 关于登录部分:

My recommendation is that as an application developer you should not be thinking in how to implement your login page. 我的建议是,作为应用程序开发人员,您不应该考虑如何实现登录页面。 This would bind your application to a specific authentication mechanism, and its a sign of getting into troubles (implementing the whole app security by your own) 这会将您的应用程序绑定到特定的身份验证机制,这是麻烦的一种信号(由您自己实现整个应用程序的安全性)

It is preferable that this binding is performed in a pluggable (declarative) way, like it is done in JEE by the container or in Spring security by a dedicated framework. 最好以可插拔(声明式)的方式执行此绑定,就像在JEE中通过容器或在Spring安全性中通过专用框架进行的绑定一样。

So answering your question: you should no have a login.jsp at all, this page would be automatically generated once you have properly configured your application security with a 'login form' authentication mechanism. 因此,请回答您的问题:根本不应该具有login.jsp ,一旦使用“登录表单”身份验证机制正确配置了应用程序安全性,此页面就会自动生成。 (Both JEE and Spring provide also mechanisms for customizing this pages). (JEE和Spring都提供了定制此页面的机制)。

The framework/container would intercept the request to your web app, identify if the user is authenticated, redirect to the login page and finally redirect to the original url, if authentication succeeds. 框架/容器将拦截对您的Web应用程序的请求,确定用户是否已通过身份验证,如果身份验证成功,则重定向到登录页面,最后重定向到原始URL。

Cheers, Nacho 干杯,纳乔

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM