我正在运行tomcat 8 / spring 5.4.1 / Tapestry 5.4.1设置。我有一个带有布局组件的简单模板。该模板调用一个获取人数的spring服务。简单。奇怪的是,索引模板被加载了两次,看起来它是由于t:type =" layout" index.tml页面中的标记,它引用了布局组件。如果我删除它,它只会被调用一次。
这是来自tomcat的日志,清楚地显示索引被调用两次。
> 2016-07-01 09:47:39 INFO PageLoader:213 - Loaded page 'Index' (en) in 302.278 ms
> 2016-07-01 09:47:39 INFO Index:25 - [Index] onActivate
> 2016-07-01 09:47:39 INFO Index:20 - [Index] setupRender
> 2016-07-01 09:47:39 INFO Index:31 - [Layout] setupRender
> 2016-07-01 09:47:39 INFO Index:30 - [Index] getPersonCount
> 2016-07-01 09:47:40 INFO QueryTranslatorFactoryInitiator:47 - HHH000397: Using ASTQueryTranslatorFactory
> Hibernate: select count(*) as col_0_0_ from person person0_
> 2016-07-01 09:47:40 INFO Index:25 - [Index] onActivate
> 2016-07-01 09:47:40 INFO Index:20 - [Index] setupRender
> 2016-07-01 09:47:40 INFO Index:31 - [Layout] setupRender
> 2016-07-01 09:47:40 INFO Index:30 - [Index] getPersonCount
> Hibernate: select count(*) as col_0_0_ from person person0_
Index.tml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html t:type="layout" t:pageTitle="Admin Main" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd" xmlns:p="tapestry:parameter">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<title></title>
</head>
<body>
${personCount}
</body>
</html>
Layout.tml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" xmlns:p="tapestry:parameter">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<title></title>
<link rel="stylesheet" type="text/css" href="dev/css/bootstrap.css"/>
<link rel="stylesheet" type="text/css" href="dev/css/main.css"/>
<script src="dev/js/jquery-2.2.4.js"></script>
<script src="dev/js/bootstrap.js"></script>
</head>
<!-- Page Body -->
<body>
<div id="mainContainer" class="container">
<t:body/>
</div>
</body>
</html>
答案 0 :(得分:0)
可能是您在执行Hibernate调用后尝试返回HomePage。如果您在Hibernate调用执行后观察到您的页面再次加载