JSF的小问题
现有一JSF页面:
<%@ taglib uri= "http://java.sun.com/jsf/core " prefix= "f "%>
<%@ taglib uri= "http://java.sun.com/jsf/html " prefix= "h "%>
<%@ taglib uri= "http://java.sun.com/jstl/core " prefix= "c "%>
<html>
<head>
<title> My JSP 'jstl2.jsp ' starting page </title>
</head>
<body>
<f:view>
<jsp:useBean class= "com.bait.market.example1.TestForm " id= "exampleBean " scope= "session " />
<h1>
<h:outputText value= "Example of using JSF and JSTL expression languages " />
</h1>
<h:form>
<h:outputLabel for= "inputInt ">
<h:outputText value= "How many times do you want to repeat the Oracle 's prophecy? " />
</h:outputLabel>
<h:inputText id= "inputInt " value= "#{sessionScope.exampleBean.number} " />
<h:commandButton value= "Go! " />
<p>
<c:if test= "${sessionScope.exampleBean.number > 0} ">
<c:forEach begin= "0 " end= "${sessionScope.exampleBean.number - 1} " var= "count ">
Queen Tracey will achieve world domination. <br>
</c:forEach>
</c:if>
</p>
</h:form>
</f:view>
</body>
</html>
在Tomcat下运行时出现异常:
javax.servlet.ServletException: Error Parsing /pages/jstl2.jsp: Error Traced[line: 1] The markup in the document preceding the root element must be well-formed.
javax.faces.webapp.FacesServlet.service(FacesServlet.java:154)
这是什么原因?
[解决办法]
把 <html> <body> 去掉, <f:view> 是根节点