![](/img/trans.png)
[英]Error 500--Internal Server Error java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config
[英]JSF missing “javax/servlet/jsp/jstl/core/Config” on a xhtml file
我正在處理面板組選擇菜單,只有在第一個選擇菜單未設置為“P”或“N”時才可見。 我找到了一個例子,但在我嘗試之前,我得到了一個錯誤說明
java.lang.NoClassDefFoundError: javax/servlet/jsp
/jstl/core/Config
這很奇怪,因為我確信我使用的是jsf 2.2。 我擁有項目庫的唯一jar文件是:
javax.faces-2.2.5.jar
下面是我根據我發現的一個例子編寫的新代碼部分。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" >
<h:body>
<h:form>
<b>Blue tooth test: </b>
<h:selectOneMenu value="#{qcFormBean.dliStickerValue}">
<f:selectItem itemValue="P" itemLabel="Pass" />
<f:selectItem itemValue="N" itemLabel="N:A" />
<f:selectItem itemValue="M" itemLabel="FAIL-Mechanical" />
<f:selectItem itemValue="E" itemLabel="FAIL-Electrical" />
<f:selectItem itemValue="C" itemLabel="FAIL-Cosmetic" />
<f:selectItem itemValue="S" itemLabel="FAIL-Software" />
<f:ajax event="change" execute="@this" render="perfbyDliSticker" />
</h:selectOneMenu>
<h:panelGroup id="perfbyDliSticker">
<h:selectOneMenu value="#{qcFormBean.stickerFreq}"
rendered="#{!qcFormBean.dliStickerValue eq 'P' or !qcFormBean.dliStickerValue eq 'N'}">
<f:selectItem itemValue="O" itemLabel="Often" />
<f:selectItem itemValue="S" itemLabel="Seldom" />
</h:selectOneMenu>
有什么我做錯了或是我試圖渲染這個不是JSF-ish或我錯過了更多的文件因為我之前添加了這些文件
jsf-api.jar jstl-1.2.jar jsf-impl.jar
但后來我在eclipse中遇到一個tomcat錯誤,說該文件現在是一個jsp文件而不是一個jsf文件,需要添加到web.xml中。 所以必須有其他一些方法。
------更新------
我的代碼更改在這里是更新:
<h:selectOneMenu value="#{qcFormBean.dliStickerValue}">
<f:selectItem itemValue="P" itemLabel="Pass or Not applicable" />
<f:selectItem itemValue="M" itemLabel="FAIL-Mechanical" />
<f:selectItem itemValue="E" itemLabel="FAIL-Electrical" />
<f:selectItem itemValue="C" itemLabel="FAIL-Cosmetic" />
<f:selectItem itemValue="S" itemLabel="FAIL-Software" />
<f:ajax event="change" execute="@this" render="perfbyDliSticker" />
</h:selectOneMenu>
<h:panelGroup id="perfbyDliSticker">
<h:selectOneMenu value="#{qcFormBean.performedByRoleID}"
rendered="#{!qcFormBean.dliStickerValue eq 'P'}">
<f:selectItem itemValue="A" itemLabel="Always" />
<f:selectItem itemValue="O" itemLabel="Often" />
<f:selectItem itemValue="S" itemLabel="Seldom" />
</h:selectOneMenu>
--update 2 _-----添加我的web.xml以查看它是否有幫助。
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<description>State saving method: 'client' or 'server' (default). See JSF Specification section 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<welcome-file-list>
<welcome-file>index.jsf</welcome-file>
<welcome-file>welcome.jsf</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
該錯誤告訴缺少類javax.servlet.jsp.jstl.core.Config
。 此類是JSTL的一部分,默認情況下不在Tomcat上提供。
您必須確保/WEB-INF/lib
存在jstl-1.2.jar
(與JSF api和impl jar一起)。
也可以看看:
一個好的結構化的xhtml可能是這樣的( <h:head>...</head>
對於jsf ajax很重要):
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
>
<h:head>
<meta charset="UTF-8" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<h:outputStylesheet name="stylesheet.css"/>
<title>Test</title>
</h:head>
<body>
<f:view>
<h:outputText value="hello"></h:outputText>
.....
</f:view>
</body>
</html>
如果仍有該錯誤,請嘗試以下操作:
在eclipse中創建一個新的動態Web項目(Kepler EE):
1)菜單項文件 - >新建 - >動態Web項目
2)然后輸入您的項目的名稱
3)目標運行時(您的tomcat服務器)
4)模塊版本3.0
5)配置:Java Server Faces 2.2項目
6)next-> next->,然后選中“生成web.xml ...”復選框
7) next - > JSF實現庫(類型:用戶庫):在右側,您會看到一個可供下載的圖標(單擊它,然后等待,您將獲得Mojarra 2.2 ...),選擇並安裝它,完成!
之后復制我的上面的xhtml並在你的Pages中測試它(不要忘記在你的web.xml中添加你的Faces Servlet模式在URL中)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.