ype Exception report
message An exception occurred processing JSP page /index1.jsp at line 14
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /index1.jsp at line 14 11: <body> 12: hello 13: 14: <h:form id="form1"> 15: <h:inputText value="input"/> 16: <h:outputText value="h:output"/> hello锛� 17: </h:form>> Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:574) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:461) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:568) com.sun.faces.application.view.JspViewHandlingStrategy.executePageToBuildView(JspViewHandlingStrategy.java:363) com.sun.faces.application.view.JspViewHandlingStrategy.buildView(JspViewHandlingStrategy.java:153) com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:99) com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
再三排查web.xml 和 faces-config.xml的配置都没错,最后发现是jsp页面少了 <f:view> 标签。
jsp 代码如下:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%> <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title> Autotest here</title> </head> <body> hello <f:view> <h:form id="form1"> <h:inputText value="input"/> <h:outputText value="h:output"/> hello! </h:form>> </f:view> <% out.println("name:--------------"); %> </body> </html>
浏览器输入:http://localhost:8080/autotest/index1.jsp 则报错,输入http://localhost:8080/autotest/index1.jsf 则页面能正常展示
web.xml 文件不能配有这段代码,否则输入http://localhost:8080/autotest/index1.jsf页面报错
<servlet-mapping> <servlet-name>FacesServlet</servlet-name> <url-pattern>*.jsp</url-pattern> </servlet-mapping>
报错异常为:
type Exception report
message Servlet execution threw an exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)