代码拉取完成,页面将自动刷新
同步操作将从 float.lu/spring-mvc-co 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
Spring MVC CO基于Spring MVC开发,对BigPipe进行支持。基本思想是模块化的页面包含多个模块而其中有些模块可能存在数据准备慢的情况,这个时候我们不应该让页面响应的速度等于最慢的那个模块的响应时间,而是能让最快准备好数据的那个模块先渲染然后吐给客户端,我们有可能放弃渲染石板的那个模块而不是放弃整个页面。
开始: 1.Spring MVC配置文件引入Spring-mvc-co的命名空间:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc/co"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc/co
http://www.springframework.org/schema/mvc/spring-mvc-co.xsd">
<mvc:annotation-driven>
</mvc:annotation-driven>
</beans>
同时配置annotation-driven。 2.基于Freemarker的模板编写,该模板包括同步返回的DOM结构和引入的模块配置。
<#assign co=JspTaglibs["http://www.springframework.org/co"]>
<@co.config timeout=3000/>
${index!}
模块1:
<@co.module mapping="/co/module1"/>
模块2:
<@co.module mapping="/co/module2" />
说明: <@co.config timeout=3000/> 代表页面模块的超时时间为3s,超过该时间的模块将被放弃。 <@co.module mapping="/co/module1"/>配置引入的模块,和RequestMapping对应。
Controller例子:
@Controller
@RequestMapping("co")
public class CoController {
@RequestMapping("index")
public String index(Model model, String name){
model.addAttribute("index", name);
//返回数据和模板,同步返回
return "co/index";
}
//ModelAndView并发执行和渲染
@RequestMapping("module1")
public String module1(Model model, String name){
model.addAttribute("module1", name);
try {
//业务逻辑
Thread.sleep(1000);
} catch (Exception e) {
}
//模块模板
return "co/module1";
}
//ModelAndView并发执行和渲染
@RequestMapping("module2")
public String module2(Model model, String name){
model.addAttribute("module2",name);
try {
//业务逻辑
Thread.sleep(800);
} catch (Exception e) {
}
//模块模板
return "co/module2";
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。