我在学习Help中WTP Tutorials - JavaServer Faces Tools Tutorial中的例子
配置都完成了,插入一个纯jsp网页运行也没问题,可是在随意插入一个commandButton之后出现如下错误。
org.apache.jasper.JasperException: An exception occurred processing JSP page /login.jsp at line 129: </head>
10: <body>
11: 
12: <f:view>
13: <h:form>
14:  <h:commandButton></h:commandButton>
15: </h:form>请问各位大虾,问题可能出在哪?
源程序如下
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%><%@taglib
uri="http://java.sun.com/jsf/html" prefix="h"%><%@ page language="java" contentType="text/html; charset=GB18030"
    pageEncoding="GB18030"%>
<!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=GB18030">
<title>Insert title here</title>
</head>
<body><f:view>
<h:form>
<h:commandButton></h:commandButton>
</h:form>
</f:view>
</body>
</html>小弟谢谢各位了,顶者有分!

解决方案 »

  1.   

    这样试试!
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <%@taglib 
    uri="http://java.sun.com/jsf/html" prefix="h"%> <%@ page language="java" contentType="text/html; charset=GB18030" 
        pageEncoding="GB18030"%> 
    <!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=GB18030"> 
    <title>Insert title here </title> 
    </head> 
    <body> <f:view> 
    <h:form id="simpleForm"> 
    <h:commandButton id="submit" value="提交" > </h:commandButton> 
    </h:form> 
    </f:view> 
    </body> 
    </html> 
      

  2.   

    自己解决了,是url mapping的默认face被我删除的问题,可之前之所以删除是因为tomcat运行时url直接加入/faces/*路径,导致运行路径有误
    这次试探性的没把/faces/*删除,竟然好用了.楼上这位朋友的代码我试了,还是有问题,不过还是谢谢您!
      

  3.   

    顺便问一句,/faces/*为什么要加这么一个路径映射?是不是还是跟我原始配置有关系?还是jsf默认必须加的?
    谢谢了!
      

  4.   

    可是我在原始配置里面没有写/faces/*的地方啊?
    M_song 你也有这个默认值么?ps:谢谢M_song!
      

  5.   

    我就是在eclipse的preferences->web and xml->javaserver faces tools->libraries配置的
    把jsf和jstl导入就成了,甚至没有写参数的地方。所以觉得莫名其妙。ps:谢谢M_song的关注,中午前我就结贴。
      

  6.   

    客户端浏览器上 WEB 控件产生的事件,被包含在一个 HTTP 请求中,放在一起还有如浏览器类型、请求地址等其它信息。因此,所有需要 Faces servlet 处理的请求必须指向这个 servlet 。那你怎样通过调用 Faces servelt 来处理每个 HTTP 请求呢?很容易,只需要在配置描述符里用一个 servlet-mapping 元素把一个特殊的 URL 式样映射到 Faces servlet。通常,你会用到 /faces/* 样式,如下所示;
    <!-- Faces Servlet -->
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet><!-- Faces Servlet Mapping -->
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>