I created simple page using c:forEach tag. Its working in tomcat 6. But not working tomcat 7. Developed simple web application using JSF 2.0.
I run my code in tomcat 6. its working.
I deployed in tomcat 7. Its not working. c:forEach tag result not appearing.
welcomeJSF.jsp
/p>
"http://www.w3.org/TR/html4/loose.dtd">
I used the following jar
1. jsf-api.jar
2. jsf-impl.jar
3. jstl-1.2.jar
4. standard.jar
web.xml
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">
javax.faces.PROJECT_STAGE
Development
Faces Servlet
javax.faces.webapp.FacesServlet
1
Faces Servlet
/faces/*
30
faces/welcomeJSF.jsp
faces-config.xml
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">
simpleDemo
com.tomcat.foreach.SimpleDemo
session
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 userBeanList = new ArrayList();
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 getUserBeanList(){
return userBeanList;
}
public void setUserBeanList(List 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;
}
}
Help me,
Thanks in advance.
解决方案
Remove standard.jar. It's from JSTL 1.1 and conflicting with your JSTL 1.2.
See also: