English 中文(简体)
Struts-在任何作用域中都找不到bean
原标题:Struts - Cannot find bean in any scope

我使用eclipse和原生Struts实现了一个应用程序,hybernate支持在页面中显示一系列链接。我收到错误:

javax.servlet.jsp.JspException: Cannot find bean: "ListeActeur" in scope: "session"

我检查了很多网站和论坛,似乎没有什么能解决这个问题。

我的struts配置:

<struts-config>
<form-beans type="org.apache.struts.action.ActionFormBean">
  <form-bean name="ListeActeur" type="mesForms.strust.ListeActeur"/>
  <form-bean name="vérifCritère" type="mesForms.strust.vérifCritère"/>
</form-beans>
<action-mapping>
    </action>   
    <action path="/Liste" 
    parameter="/vue/Invitation.jsp"
    name="ListeActeur     scope="request       validate="false"
                     type="mesAction.struts.ListeActeurAction">  
    <forward name="s" path="/vue/NewFile.jsp" redirect="false" /> 
    </action>
</action-mappings>
</struts-config>

ListActeurAction:

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest req, HttpServletResponse res) throws Exception {
        System.out.println("Action");

        ListeActeur ListeActeur= (ListeActeur) form;
        String query = "select * from Acteur " ;

        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
         Iterator results = session.createSQLQuery(query).list().iterator();
         List <Acteur> lis = new ArrayList<Acteur>();
         while((results.hasNext()))
         {
             Acteur gg =new Acteur();
            Object[] row = (Object[]) results.next();
            gg.setActeurId((Integer)row[0]);
            gg.setNomActeur((String)row[2]);

             lis.add(gg);
         }
         req.getSession(true).setAttribute("lis", lis);
         session.getTransaction().commit();
         HibernateUtil.getSessionFactory().close();             
        ListeActeur.setLis( lis);
        req.setAttribute("formu", ListeActeur.getLis());

        return mapping.findForward("s");
        }
}

讲师:

public class ListeActeur extends ActionForm {

private  List <Acteur> lis=null;

public List <Acteur> getLis(){
    return lis;}
public void setLis(List <Acteur> lis){this.lis=lis;}
public void reset(ActionMapping mapping, HttpServletRequest request) { 

    lis = new ArrayList<Acteur>();  
}

我真的不知道该怎么办。我是Struts的新手。提前感谢!

问题回答

你有

<action path="/Liste" scope="request" .../>

<logic:iterate ... scope="session" >

难怪你会得到这个例外。如果将Struts配置为在请求中存储表单bean,则不要尝试从JSP中的会话中获取它。





相关问题
JSP link submitting data to struts form bean

I am making a JSP page that links to a page where it will pull a list of data from the database depending on the user who is logged in. I am using a DataSourceRealm type authentication so I pull the ...

Populate values using optionCollection Tag in struts1

I have an arraylist which contains {1,2,3,4,5} as objects. i want to show these values in dropdown select box. how do i achieve it. how to map with value and label property?

Eclipse Dynamic Web Project fails to load under WTP

When trying to run an Eclipse Dynamic Web Project under a Tomcat setup using WTP, it fails with the attached stacktrace. Checklist At the project properties, under "Java EE Module Dependencies" I ...

How to use javascript to include struts html tag?

I have a check box and a text box. I have used struts tags and Now i need to validate that if the check box is checked, i should gray out (disable) the text box. If it is unchecked the text box ...

Struts 1 - How to display ActionMessages

I am displaying ActionMessages through a JSP file by the following command: <logic:messagesPresent message="true"> <ul id="messsages"> <html:messages id=&...

AJAX with Struts 1.x Version

I am having an application developed with Struts1.3, Jboss4.X version and jdk1.5 Now as an enhancement we are planning to implement AJAX to the web application Can you please suggest me Whether I ...

Using Bean Class variable into the Jsp (UI layer) in java

I want to use "if condition and while loop" in struts1 framework. I have a Bean class with setter() and getter() methods for fname and lname property. How to use that bean variable in jsp for checking ...

热门标签