我将netbeans与glassfish一起使用
在我.xhtml文件中,有一个我希望将其称为操作shopBean.instructorScheduleById()的链接
<p:commandLink styleClass="tooltip tour-sched"
rendered="#{shopBean.instructorSchedule!=null}"
update=":dialogFormTS" action="#
{shopBean.instructorScheduleById()}"
oncomplete="dlgTS.show()" process="@this"
ajax="true">TS<h:outputText styleClass="tooltiptext"
value="#{shopBean.instructorSchedule.name}"/>
</p:commandLink>Bean文件
@ManagedBean(name = "shopBean")
@SessionScoped
public class ShopBean {
public ShopBean() {}
public void getInstructorScheduleById(){
System.out.println("hello");
}
}我查看了network下的开发人员工具,发现有一个ajax请求,但当我查看glassfish输出时,却没有hello一词
发布于 2017-05-30 13:16:40
根据我在stackoverflow上学到的,get前缀用于getter方法,这意味着它必须有一个返回值。
public void sum(){
int num1 = 1;
int num2 = 2;
System.out.println(num1 + num2);
}
// xhtml
<p:commandButton action="#{bean.sum()}" />如果想要从getter方法中获取值:
pivate int sum;
public int getSum(){
return this.sum;
}
public void setSum(sum){
this.sum = sum;
}
// xhtml
<p:outputText value="#{bean.sum}" />问题的快速解决方案是删除bean中的get前缀。
https://stackoverflow.com/questions/44252488
复制相似问题