【发布时间】:2015-11-15 16:04:58
【问题描述】:
我想使用 icefaces,但是一旦我导入 icefaces 库,我的 web 应用程序会在单击表单上的一个按钮后崩溃,该按钮在导入前可以正常工作。
会出什么问题?
Java 源代码:
package test,
import javax.faces.bean.ManagedBean;
@ManagedBean
public class Student {
private String firstName;
// create no-arg constructor
public Student() {
}
// define getter/setter methods
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
}
index.xhtml:
<!DOCTYPE html>
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Student Registration Form</title>
</h:head>
<h:body>
<h:form>
First name: <h:inputText value="#{student.firstName}" />
<br/><br/>
<h:commandButton value="Submit" action="student_response" />
</h:form>
</h:body>
student_response.xhtml
<!DOCTYPE html>
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<title>Student Confirmation</title>
</h:head>
<h:body>
The student is confirmed: #{student.firstName}
</h:body>
</html>
【问题讨论】:
-
你从哪里得到 IceFaces 包?您正在复制
javax.faces、javax.servlet、javax.annotation等 API。 -
确实,运行时类路径是一团糟。看起来 JAR 是随意扔进去的。从 WAR 中删除重复的和容器生产的 JAR。