我尝试使用prime faces库设置JSF项目当我运行此设置时,它显示跟随错误
org.apache.jasper.JasperException: javax.servlet.ServletException: null source
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:54
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Run Code Online (Sandbox Code Playgroud)
我无法找到背后的原因.
以下是设置
Folloing是我在web-inf/lib中包含的库
1. jsf-api-2.0.3.jar
2. jsf-impl-2.0.3.jar
3. jstl-1.0.2.jar
4. primefaces-3.4.jar
以下是web.xml文件的委托
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>primefaces.skin</param-name>
<param-value>none</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<listener>
<listener-class>
com.nsf.ecap.web.base.ECapStartUpServlet
</listener-class>
</listener>
</web-app>
Run Code Online (Sandbox Code Playgroud)
login.xhtml
<h:body>
<CENTER>
<h:panel header="Login Form">
<h:Form>
<h:PanelGrid columns="2" cellpadding="2">
<h:outputLabel value="UserName" for="#{loginBBean.userInfo.username}"> </h:outputLabel>
<h:inputText value="#{loginBBean.userInfo.username}" label="UserName"> </h:inputText>
<h:outputLabel value="Password" for="#{loginBBean.userInfo.password}"></h:outputLabel>
<h:inputSecret value="#{loginBBean.userInfo.password}"></h:inputSecret>
<h:commandButton value="Login" type="submit" action="#{loginBBean.doLogin}"></h:commandButton>
</h:PanelGrid>
<h:messages>
</h:messages>
</h:Form>
</h:panel>
</CENTER>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
的index.jsp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<jsp:forward page="jsp/login/login.jsf"/>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
"我的JSP'index.jsp'起始页"?请阻止/忽略/抛弃您正在阅读的教程.这只会让你完全混淆并教导你不好的做法.
至于你的图书馆清单:
Folloing是我在web-inf/lib中包含的库
- JSF的API-2.0.3.jar
- JSF的IMPL-2.0.3.jar
- JSTL-1.0.2.jar
- primefaces-3.4.jar
首先,JSTL版本是错误的.它应至少为JSTL 1.1或最好为1.2.EL(表达语言,那些${}/ #{})的东西否则将无法工作.删除jstl-1.0.2.jar并将jstl-1.2.jar放到位.
此外它看起来还不错.只有你拥有超过2年的JSF API/impl版本,而你最近(不到2周)的PrimeFaces版本,我才会感到惊讶.我将这些JSF API/impl版本与最新版本对齐.它目前已经在2.1.13(注意:它现在只由一个JAR文件javax.faces.jar而不是两个JAR文件组成).
至于你的web.xml:
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
Run Code Online (Sandbox Code Playgroud)
这被声明符合Servlet 2.5规范已经超过6年.你确定你正在运行这样一个过时的容器吗?鉴于存在JSF和JSTL库,我假设您正在使用Tomcat.当前的Tomcat版本7.x已经存在了2年多,并且与Servlet 3.0兼容.您应该声明您web.xml的匹配目标容器的最高支持版本.
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
Run Code Online (Sandbox Code Playgroud)
此外,这些javax.faces.STATE_SAVING_METHOD和javax.faces.DEFAULT_SUFFIX条目已经表示默认值.只需摆脱它们以减少噪音.
至于你的login.xhtml:
<h:Form>
<h:PanelGrid columns="2" cellpadding="2">
Run Code Online (Sandbox Code Playgroud)
标签名称区分大小写.在<h:Form>和<h:PanelGrid>不存在的.它是<h:form>和<h:panelGrid>.
<CENTER>
Run Code Online (Sandbox Code Playgroud)
虽然不是立即出现问题,但是这个HTML元素自1998年以来就被弃用,而不是CSS.另外,在<center>90年代以前的HTML风格中,以大写的味道而不是(通常是90年代的HTML风格)看到它并不会让我觉得你正在阅读最新和正确的书籍/教程来学习网页开发.您应该确保您的学习资源是最新的.
至于你index.jsp:这完全没用.完全删除它.只需改变你web.xml的
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
Run Code Online (Sandbox Code Playgroud)
至
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>login.xhtml</welcome-file>
</welcome-file-list>
Run Code Online (Sandbox Code Playgroud)
login.xhtml当您/在Web浏览器中访问时,这种方式将显示为"主页" .请注意,您不应该也不需要*.jsfURL模式.
| 归档时间: |
|
| 查看次数: |
5983 次 |
| 最近记录: |