我有一个使用 joy-5.0.13 构建的应用程序,我无法将一些变量值发送到要在屏幕上呈现的模板。我敢肯定,我现在缺少一些简单的东西。
这是我的行动:
@MadvocAction
public class IndexAction {
@PetiteInject
private TemperatureService temperatureService;
@Out
List<TemperatureLog> temps;
@Action
public void view() {
temps = temperatureService.getLastHoutTemperatures();
System.out.println(temps);
}
这是名为 index.jsp 的文件
<%@ taglib prefix="j" uri="/jodd" %>
<html>
<head>
<title>SmartHome</title>
</head>
<body>
<j:iter items="${temps}" var="tl">
${tl.temperature}<br/>
</j:iter>
</body>
</html>
这是来自控制台的日志:
80281 [DEBUG] j.m.c.MadvocController.invoke:102 - Action path: GET /index
80281 [DEBUG] j.m.c.MadvocController.invoke:125 - Invoke action for '/index' using ro.videanuadrian.sh.action.IndexAction#view
80291 [DEBUG] j.j.i.LocalizationUtil.setRequestBundleName:78 - Bundle name for this request: ro.videanuadrian.sh.action.IndexAction
80297 [DEBUG] j.j.JtxTransactionManager.requestTransaction:272 - Requesting TX jtx{Required,readonly,Read Committed,-1}
80299 [DEBUG] j.j.JtxTransaction.<init>:102 - New JTX {status:Active, mode:jtx{Required,readonly,Read Committed,-1}}
80321 [DEBUG] j.d.j.DbJtxSessionProvider.getDbSession:57 - Requesting db TX manager session
80322 [DEBUG] j.d.DbSession.<init>:60 - Creating new db session
80323 [DEBUG] j.d.j.DbJtxResourceManager.beginTransaction:71 - begin jtx
80325 [DEBUG] j.d.DbSession.beginTransaction:242 - Beginning transaction
80325 [DEBUG] j.d.p.CoreConnectionPool.getConnection:256 - Returning valid pooled connection
80443 [DEBUG] j.d.DbQueryBase.execute:686 - Executing statement: SELECT tt.id, tt.sensor_id, tt.temperature, tt.timestamp FROM sh_temperature_log tt WHERE tt.timestamp>1577460508000 ORDER BY tt.id ASC
80503 [DEBUG] j.d.DbQueryBase.execute:704 - execution time: 70ms
80526 [DEBUG] j.j.w.LeanJtxWorker.maybeCommitTransaction:93 - commit tx
80526 [DEBUG] j.j.JtxTransaction.commitOrRollback:255 - Commit JTX
80526 [DEBUG] j.d.j.DbJtxResourceManager.commitTransaction:83 - commit jtx
80526 [DEBUG] j.d.DbSession.commitTransaction:254 - Committing transaction
80614 [DEBUG] j.d.DbSession.closeSession:84 - Closing db session
[TemperatureLog [sensorId=1, timestamp=1577535822000, temperature=23.0], TemperatureLog [sensorId=1, timestamp=1577535826000, temperature=24.0], TemperatureLog [sensorId=1, timestamp=1577535829000, temperature=25.0], TemperatureLog [sensorId=1, timestamp=1577535844000, temperature=26.5]]
80623 [DEBUG] j.m.c.MadvocController.render:202 - Result type: ServletDispatcherActionResult
80623 [DEBUG] j.m.r.AbstractTemplateViewActionResult.render:91 - new target: /index:
80623 [DEBUG] j.m.r.ServletDispatcherActionResult.targetExists:105 - target check: /index.jspf
80624 [DEBUG] j.m.r.ServletDispatcherActionResult.targetExists:105 - target check: /index.jsp
80625 [DEBUG] j.m.r.AbstractTemplateViewActionResult.render:102 - target found: /index.jsp
但在视图中我只得到:${tl.temperature}
这就像它没有到达视图引擎的结果。我进行了一些调试,似乎 actionResult 为空。
知道我在做什么错吗?
谢谢
PS我已经尝试过toturial,但我遇到了同样的问题:
Messages
${msg.messageId} ${msg.text}
${resp.responseId} ${resp.text}
new message...
REST APi: message 1
那是我的输出