与AngularJS整合JSP,它是在现实世界中关注的问题...... Beginer在角JS [英] Integrating JSP with AngularJS, Is it a concern in real world...Beginer in Angular JS

查看:379
本文介绍了与AngularJS整合JSP,它是在现实世界中关注的问题...... Beginer在角JS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉您的意见,以确保,我要去学习角JS的正确方向。

Please tell your comments, to make sure, I'm going in a right direction of learning Angular JS.

我是新来AngularJS但设法运行包含AngularJS code JSP文件,并做了一个试验计算/添加和它的工作好。

I'm new to AngularJS but managed to run a jsp file which contain AngularJS code, and made a test calculation/addition and it worked good.

后来,当我搜索网站论坛,我才知道他们都是不应该一起工作,因为它可以带来麻烦。

Later when I search web forums, I came to know they are both not supposed to work together as it can cause trouble.

我使用NetBeans和GlassFish应用服务器,专家/大师的让我知道如果我在一个错误的方向我要去。

I've used netbeans and GlassFish Server, Expert's/Guru's let me know If I'm going in a wrong direction.

谢谢,
JG

Thanks, JG

推荐答案

我不混用的SPA一个Servlet / JSP技术(单页的应用程序通过....角在您的案件驱动)。您的什么能有一个JSP其中的 的做的是使用用SpringMVC一样(或州)的工具,是的角度的驱动SPA。这样,你有很多的控制权初始HTML / JS / CSS有效载荷在最初的反应。一旦应用被加载,所有与服务器它的通信是通过XHR调用完成($ http或$在角资源)。春天使这个pretty简单的创建一个使用@Controller,给你所有你需要的灵活性......事情好象春天到了安全性和依赖注入。

I wouldn't mix a Servlet/JSP tech with an SPA (single page app....driven by angular in your case). What you can do is use a tool like SpringMVC (or Jersey) that has a single JSP which is your angular driven SPA. That way you have lots of control over the initial HTML/JS/CSS payload in the initial response. Once that "app" is loaded, all it's communication with the server is done via XHR calls ($http or $resource in angular). Spring makes this pretty simple to create using @Controller and giving you all the flexibility you need... things like spring security and dependency injection.

我在我的业余时间一直在研究一些简单的就像这帮助Java服务器端的人进入角。

I've been working in my spare time on something simple just like this to help java server side people get into Angular.

这个想法是,你有一个控制器,它返回一个JSP,当你犯了一个GET请求

the idea is that you'd have a controller that returns a JSP when you make a GET request to

http://your.site.com/contextRoot

这页将有JS / CSS链接加载引导/ JQuery的/角/不管......从那里角路由器会踢在你的URL可能最终会像这样

That page would have the JS/CSS links to load Bootstrap/JQuery/Angular/Whatever... From there the angular router would kick in and your URL might end up like this

http://...../contextRoot#home

在JSP之间的所有通信运行在客户机上的角度和服务器与$ HTTP调用完成,你可以在Spring的控制器来处理这一切。

All communication between the JSP running angular on the client and the server is done with $http calls and you can make controllers in Spring to handle all this.

我会后回到这里,一旦我有我的可用Springular应用

I'll post back here once I have my "Springular" app available

这篇关于与AngularJS整合JSP,它是在现实世界中关注的问题...... Beginer在角JS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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