尝试从包含的 JSP 调用 Action 的 getter,我得到 null:
MyAction.java
private String message = "The message I want to read...";
public String getMessage() {
return message;
}
主.jsp
<%@taglib prefix="s" uri="/struts-tags" %>
<html>
<head></head>
<body>
<div> I'm a DIV in main.jsp </div>
<jsp:include page="fragment.jsp" />
<body>
</html>
片段.jsp
<%@taglib prefix="s" uri="/struts-tags" %>
<div>
I'm a DIV from fragment.jsp
<br/>
Message from Action: <s:property value="message" />
</div>
如何获取 JSP 片段中的属性值?