简体   繁体   English

需要有关如何制作 Angular 应用程序和 Java 作为后端的建议

[英]Need advice on how to make an Angular app and Java as backend

I'm a not a programmer but a programming enthusiast, I have learned java (specifically - basics, some of the advanced stuff, JDBC, collections, servlets, etc. I haven't learned any frameworks such as swing, spring, applets, etc. I have created a web app as my project after I learned java with servlets, HTML, CSS, jQuery. I used no frameworks of any sought. I started learning Angular 7 and I'm in the middle of it. I used servlets to manage my sessions for client-side and was very easy to talk to using post request using jquery and receive Z0ECD11C1D7A287401D148A23BBD7A2F8 I'm a not a programmer but a programming enthusiast, I have learned java (specifically - basics, some of the advanced stuff, JDBC, collections, servlets, etc. I haven't learned any frameworks such as swing, spring, applets, etc. I have created a web app as my project after I learned java with servlets, HTML, CSS, jQuery. I used no frameworks of any sought. I started learning Angular 7 and I'm in the middle of it. I used servlets管理我的客户端会话,使用 jquery 和接收 Z0ECD11C1D7A287401D148A23BBD7A2F8 使用发布请求非常容易Z obj in return, I used JSP to render the HTML code I wanted. Z obj 作为回报,我使用 JSP 来渲染我想要的 HTML 代码。 So I could add a bit of code in every JSP page like so...:所以我可以像这样在每个 JSP 页面中添加一些代码......:

<%
String school=(String)session.getAttribute("school");  
if(school == "" || school == null){
    response.sendRedirect("index.jsp");
}
%>

...and redirect the user if the session is null. ...如果 session 是 null,则重定向用户。 I'm wondering what a similar solution would be in Angular since angular is independent of the server.我想知道在 Angular 中会有什么类似的解决方案,因为 angular 独立于服务器。

You could manage your sessions in a handful of ways.您可以通过多种方式管理会话。 The go to way at writing this seems to be through the use of JWT (JSON Web Token). go 似乎是通过使用 JWT(JSON Web 令牌)来编写的。 You could setup an API service in angular that handles this using HttpClient .您可以在 angular 中设置一个 API服务,该服务使用HttpClient处理此问题。 When it comes to redirecting there's a Router class for that in Angular.在重定向方面,Angular 中有一个路由器class。

I understand this might be a bit overwelming, don't hesitate to ask if you need any more information.我知道这可能有点过分欢迎,请随时询问您是否需要更多信息。 :) :)

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

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