Home>Article>Web Front-end> How to embed vue project into jsp page? (Method introduction)

How to embed vue project into jsp page? (Method introduction)

青灯夜游
青灯夜游 forward
2020-06-16 10:01:49 5033browse

How to embed vue project into jsp page? The following article will introduce to you the method of embedding jsp pages in vue projects. The article introduces it in detail through sample code. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How to embed vue project into jsp page? (Method introduction)

Embed the jsp page in the vue project

One of the functional modules in a project today is another system Using the page that has been developed by jsp, I thought about embedding it directly into the current vue project to save development costs; but I found that it was not as simple as imagined

Create a server.vue component to load the jsp page

1. The first type (using v-html for jsp rendering)

server.vue

  

The jsp data format returned by the request

How to embed vue project into jsp page? (Method introduction)

The content of index.jsp returned by the background is as follows:

    Docker容器服务器管理            

The page is displayed as follows:

How to embed vue project into jsp page? (Method introduction)

Because: the jsp page only writes a few tags, and other data is dynamically rendered through methods in external js. However, using v-html only loads the jsp page to the current page, but does not load the js again; so There are only a few useless tags on the page! It was finally confirmed that this method is not feasible

2. The second method (using iframe for jsp embedding)

Modified server.vue

  

This time, I finally got the running effect as follows:

How to embed vue project into jsp page? (Method introduction)

I still succeeded with the old-fashioned method. The test proved that this method is feasible and perfectly solved the problem. Hehe.

This article is reproduced from: https://blog.csdn.net/qq_34817440/article/details/99764511

For more related knowledge, please visitPHP Chinese website! !

The above is the detailed content of How to embed vue project into jsp page? (Method introduction). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete