尝试从包含的JSP调用Action的getter时,我得到null:
MyAction.java
private String message = "The message I want to read...";
public String getMessage() {
return message;
}main.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>fragment.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片段中获得属性值?
发布于 2013-10-17 11:42:37
使用而不是<jsp:include page="somePage.jsp"/>。
如果您想继续使用<jsp:include />,则需要设置
<constant name="struts.ognl.allowStaticMethodAccess" value="true"/> 在Struts.xml中,它将像魅力一样工作。
别问我为什么,文档中任何地方都没有提到这一点。,这是我不久前的幸运发现。
https://stackoverflow.com/questions/19425754
复制相似问题