[英]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.