先说一下为什么要从jsp过渡到vue
1.准备把系统全部升级为api项目(spring-boot restful)遗弃掉jsp,主要为了解决多项项目后台代码重用问题,项目升级为微服务(spring-cloud)架构,比如首页一个项目 后台管理一个项目中间肯定有很多重复业务代码,当然可以通过搭建私有maven源封装公共代码,本文中先不考虑这类解决方案。另外vue这类框架组件模板这些特性开发和维护起来和纯撸jQuery逻辑清晰不少。
2.项目发展大了肯定要前后端分离,当然前期肯定全栈式开发前后端两遍忙乎,但是个人感觉后期收益高于前期的辛苦。
3.jsp渲染确实慢
4.个人架构方向爱好 ,java流的技术站方向》spring-cloud+spring-boot restful+vue 这种架构。
问题1:不准备一次性重构,希望渐进式迁移(直接上全家桶不准备在jsp里面写vue代码),目前只能想到1种方案利用ngxin的location匹配url后面的路径区分是路由到原来的jsp页面还是新项目的vue|react页面,但是感觉这种方案不是特别好,希望有segmentfault前后端大神前来解惑。
问题2:大家都说SPA应用适合中后端开发,是我理解有误还是有其他原因? 电商 比如淘宝, 社交 比如QQ空间这类产品如果用SPA应用开发会有什么弊端?仅仅是因为SEO问题么?
高洛峰2017-04-18 10:29:05
I use react + antd. I feel that the biggest advantage is that it unifies the development ideas of the client and the web page. The server only needs to provide a set of rest api.
If the client is developed with react native, the workload can be further reduced.
阿神2017-04-18 10:29:05
1. I don’t dare to answer on my own if I don’t understand jsp.
2. As you said, Vue
It is not impossible to develop websites such as Taobao, social networking, QQ space and other categories. It is completely possible. On the contrary, the fluency will be better if it is made into a single page. Someone on github imitated Douban. A demo loads smoothly, especially if your website wants to support mobile devices. Even in a poor network environment, a single-page application can load very quickly.
Single-page applications are not so SEO-friendly compared to traditional web pages, and the bookmark function requires writing your own code to support it.
PHP中文网2017-04-18 10:29:05
You will find out as you write it. It is too stupid to write a display website into these front-end frameworks. There is no in-page interaction (you have to change pages with one click). The native HTML has to be rewritten according to the rules of these frameworks, which is tiring. It's meaningless and incomparable to the background template.
jsp rendering is slow. I don’t know what you are talking about. Is the background java running slow? Use the message queue to make everything that can be asynchronous asynchronous, load balancing, etc. Frontend rendering slow? JS/CSS and other static files are cached on CDN.
Mid- and back-end management platforms are very suitable for these front-end frameworks
伊谢尔伦2017-04-18 10:29:05
Since you use vue, don’t use jsp. jsp is back-end rendering. The generated page is sent to the browser, and vue is used to render it with the browser;
Use vue and java to make a single-page website. The browser visits the website for the first time. , java sends the static html page and js to the browser. When the browser clicks to jump, the front end simulates routing, and then js uses fetch and ajax to send HTTP request data. After java receives the HTTP request and returns the data, vue receives the request and obtains it. Data, re-render the display page.
Because there is no need to render the page, Java is only responsible for sending and receiving json data using REST, and the performance is definitely higher