Does Spring MVC 3.x support partial views (html / jsp) like ASP.NET MVC3 / 4?

Q1: Does Spring or any open source java UI interface support partial views in asp.net mvc?

For example, in my main index.html (or _layout.cshtm for asp.net mvc3 spec)

I would have the following code:

<span id="logindisplay">@Html.Partial("_LogOnPartial")</span> 

where @Html is a helper for displaying a partial view for _LogonPartial.cshtml, which just injected the html content into the page?

Q2: If it is supposed, If I want to display a bunch of partial views, it would be useful to display them in parallel at the same time to improve performance. Very similar to what linkedin does with dust and soda? http://engineering.linkedin.com/profile/engineering-new-linkedin-profile

Q3: Is fizzy available as open source, like dust?

+4
source share
1 answer

If you want to include the contents of the page on another page by adding the code on the page itself, you should compare asp with jsp and not ASP.NET MVC* with JEE - Spring MVC

So, the equivalent of <span id="logindisplay">@Html.Partial("_LogOnPartial")</span> on jsp would be one or all of the following

  • On your jsp, include content from another jsp using <%@ include file="../includes/inner-content.jsp" %> . This is what is called static include. The included jsp source is included and included with the parent jsp before compiling jsp. If you are using an IDE, it will verify that the included jsp does indeed take place on the specified path relative to the jsp location in which you add include. Technically, this is JSP Directive . The included jsp may just be a fragment and not addressable from the outside world (may be hidden inside WEB-INF )

  • You can also use the so-called dynamic include <jsp:include page="someJSP.jsp" /> . In this case, the included jsp should be addressable from the browser and should be able to render independently. When the server runs a servlet to display the parent JSP, it stops when this tag is viewed, and starts servlet execution for the included jsp, the result obtained from the internal jsp execution is then combined with the output of the parent jsp, and processing of the parent jsp resumes.

  • The third option is to use the Core JSTL taglib <c:import url=""/> . This works the same as option 2 above, except that it also allows you to import a page / content from a URL that lives outside of your application. Basically, you can specify a jsp path or relative URI for displaying servlets in your application or a URL to an external page.

Now I suspect that this is not what you want to do if you compare what LinkedIn does. You want to mashup content from sources in your own application and compose your page. You also want to do this in asynchronous mode so that the load verification time is checked. In this case, you need to use JavaScript and Ajax. All the mechanisms described above are intended for pages processed by the server (all HTML is created before the page is displayed in the browser). Just like @HTML . You need to create a simple structure / use the existing one, where after loading the page it launches ajax asynchronous calls to the server to receive content for certain areas on the page and displays the returned HTML in these specific areas.

Hope this helps.

Let me know if I misunderstood your question.

+11
source

Source: https://habr.com/ru/post/1485741/


All Articles