xhtml中如何调用java方法
How to call java methods in xhtml
我在使用 Primefaces 的 Spring 项目中观察到 java 方法在 xhtml 中直接调用,而不使用 servlet。
例如:
- < Some_Html_Object [...] onclick = "${FooClass.fooAction()}" />
- < Some_Html_Object [...] 值="${FooClass.fooParameter}" />
如何配置您的 Spring 项目来执行此操作?你有教程吗?
是否可以为 J2E 项目实现它?
Ps : 我是 Spring 的初学者。
感谢
在 JSF 页面中,您可以使用 Expression Language.
从 bean 调用方法
作为一个非 Spring JEE 应用程序的例子,它没有注入任何 Spring Bean。但是,您可以在 Spring 项目中使用 CDI。
@Named
@ViewScoped
public class TestBean implements Serializable{
private String documentTitle;
private String documentURL;
private ArrayList<ACMSSearchResults> acmsResults = new ArrayList<>();
public ACMSSearch(){}
public String getDocumentTitle() {
return documentTitle;
}
public void setDocumentTitle(String title) {
documentTitle = title;
}
}
您可以使用表达式语言从 JSF 页面中的 bean 调用方法
<p:label value="#{testBean.documentTitle}"/>
配置 Spring 以使用 JSF 外观的好教程 HERE
我在使用 Primefaces 的 Spring 项目中观察到 java 方法在 xhtml 中直接调用,而不使用 servlet。
例如:
- < Some_Html_Object [...] onclick = "${FooClass.fooAction()}" />
- < Some_Html_Object [...] 值="${FooClass.fooParameter}" />
如何配置您的 Spring 项目来执行此操作?你有教程吗? 是否可以为 J2E 项目实现它?
Ps : 我是 Spring 的初学者。
感谢
在 JSF 页面中,您可以使用 Expression Language.
从 bean 调用方法作为一个非 Spring JEE 应用程序的例子,它没有注入任何 Spring Bean。但是,您可以在 Spring 项目中使用 CDI。
@Named
@ViewScoped
public class TestBean implements Serializable{
private String documentTitle;
private String documentURL;
private ArrayList<ACMSSearchResults> acmsResults = new ArrayList<>();
public ACMSSearch(){}
public String getDocumentTitle() {
return documentTitle;
}
public void setDocumentTitle(String title) {
documentTitle = title;
}
}
您可以使用表达式语言从 JSF 页面中的 bean 调用方法
<p:label value="#{testBean.documentTitle}"/>
配置 Spring 以使用 JSF 外观的好教程 HERE