c:forEachタグを使用して簡単なページを作成しました。Tomcat6で動作します。しかしnot working tomcat 7
。JSF2.0を使用してシンプルなWebアプリケーションを開発しました。
私はtomcat6でコードを実行します。tomcat7にデプロイしました。動作しません。c:forEachタグの結果が表示されません。
welcomeJSF.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<f:view>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<h:form id="forEachForm" binding="#{simpleDemo.initForm}">
<c:forEach items="#{simpleDemo.userBeanList}" var="userBean" varStatus="status">
<h:panelGrid columns="2" border="1">
<h:outputText value="#{userBean.userName}"/>
<h:outputText value="#{userBean.role}"/>
</h:panelGrid>
</c:forEach>
</h:form>
</body></html></f:view>
私は次の瓶を使用しました
1. jsf-api.jar
2. jsf-impl.jar
3. jstl-1.2.jar
4. standard.jar
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/welcomeJSF.jsp</welcome-file>
</welcome-file-list>
</web-app>
faces-config.xml
<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns
/javaee/web-facesconfig_2_0.xsd">
<managed-bean>
<managed-bean-name>simpleDemo</managed-bean-name>
<managed-bean-class>com.tomcat.foreach.SimpleDemo</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>
SimpleDemo.java
package com.tomcat.foreach;
import java.util.ArrayList;
import java.util.List;
import javax.faces.component.html.HtmlForm;
public class SimpleDemo
{
private HtmlForm initForm;
private List<UserBean> userBeanList = new ArrayList<UserBean>();
public HtmlForm getInitForm()
{
userBeanList.clear();
UserBean userBean = new UserBean();
userBean.setUserName("jack");
userBean.setRole("sample Role");
userBeanList.add(userBean);
userBean = new UserBean();
userBean.setUserName("adminuser");
userBean.setRole("Admin Role");
userBeanList.add(userBean);
userBean = new UserBean();
userBean.setUserName("Test User");
userBean.setRole("Test role");
userBeanList.add(userBean);
return initForm;
}
public void setInitForm(HtmlForm initForm){
this.initForm = initForm;
}
public List<UserBean> getUserBeanList(){
return userBeanList;
}
public void setUserBeanList(List<UserBean> userBeanList){
this.userBeanList = userBeanList;
} }
UserBean.java
package com.tomcat.foreach;
public class UserBean
{
private String userName;
private String role;
public String getUserName(){
return userName;
}
public void setUserName(String userName){
this.userName = userName;
}
public String getRole(){
return role;
}
public void setRole(String role){
this.role = role;
}
}
助けてください、よろしくお願いします。