0

问题是:在我的动作类中,我有一个变量:

 private String commentAdd = "yes";

动作类转到 reslut.jsp,在 reslut.jsp 中我有:

<s:set name="allowAddComment" value="commentAdd"/>
<s:if test="%{#allowAddComment=='yes'}">
                    <script type="text/javascript">
                        window.close();
                    </script>
</s:if>

但它不起作用,有专家可以给我一些建议吗?谢谢。

4

2 回答 2

1

一些东西。

  • 该属性需要通过公共 getter 公开(或在 S2 的更高版本中作为公共成员,但最好使用 getter)。
  • 为什么使用字符串作为布尔值?只需使用布尔值。
  • 为什么将属性设置为不同的变量?只需使用该属性。

确定这真的是你想要的吗?这将在JavaScript 呈现后立即关闭窗口。如果没关系,那很好——尽管如果是这样,为什么还要费心渲染窗口呢?

于 2012-02-24T15:31:29.437 回答
0
import com.opensymphony.xwork2.ActionSupport;

public class PageAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private boolean addComment;

public boolean isAddComment() {
    return addComment;
}

public void setAddComment(boolean addComment) {
    this.addComment = addComment;
}

public String execute() {
    return SUCCESS;
}

}

<s:if test="%{addComment}">
 <script type="text/javascript">
  window.close();
 </script>
</s:if>
于 2012-02-24T15:52:32.767 回答