A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

1黑马币
action 的代码:
package cn.itcast.action;
import java.util.List;
import cn.itcast.dao.HQLDao;
import cn.itcast.hibernate.domain.Classes;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class HQLAction extends ActionSupport{
        public String getData_From_Classes(){
                List<Classes> cList = HQLDao.getInstance().queryAllClasses();
                ActionContext.getContext().put("cList", cList);
                return "allClasses";
        }       
}
dao代码
package cn.itcast.dao;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.hibernate.Query;
import org.hibernate.Session;

import cn.itcast.hibernate.domain.Classes;
import cn.itcast.hibernate.domain.Student;
import cn.itcast.util.HiberanteUtils;

public class HQLDao extends HiberanteUtils{
        public List<Classes> queryAllClasses(){
                Session session = sessionFactory.openSession();
                List<Classes> cList = session.createQuery("from Classes").list();
                session.close();
                return cList;
        }
        public static HQLDao getInstance(){
                return new HQLDao();
        }
}
struts2配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
        "http://struts.apache.org/dtds/struts-2.3.dtd">

<struts>
        <package name="hql" namespace="/" extends="struts-default">
                <action name="hqlAction_*" method="{1}" class="cn.itcast.action.HQLAction">
                        <result name="allClasses">hql.jsp</result>
                </action>
        </package>
</struts>

打开网页一直是404同事控制台还输出了
十二月 05, 2014 4:27:39 下午 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
严重: The web application [/hibernateday05] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
十二月 05, 2014 4:27:39 下午 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
严重: The web application [/hibernateday05] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@561b6dc8]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@22c491a2]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
十二月 05, 2014 4:27:39 下午 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
严重: The web application [/hibernateday05] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@17353483]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@260a905c]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
十二月 05, 2014 4:27:39 下午 org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
严重: The web application [/hibernateday05] created a ThreadLocal with key of type [com.opensymphony.xwork2.inject.ContainerImpl$10] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@17353483]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@7f8b9b86]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
log4j:WARN No appenders could be found for logger (com.opensymphony.xwork2.config.providers.XmlConfigurationProvider).
log4j:WARN Please initialize the log4j system properly.
十二月 05, 2014 4:27:41 下午 org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory hibernateday05.myeclipse.bak
log4j:WARN No appenders could be found for logger (com.opensymphony.xwork2.config.providers.XmlConfigurationProvider).
log4j:WARN Please initialize the log4j system properly.


求解决方法


最佳答案

查看完整内容

第一,重启tomcat,重新部署项目 第二,只做建设性意见,你把action的method里换成方法名试试getData_From_Classes。

1 个回复

正序浏览
第一,重启tomcat,重新部署项目
第二,只做建设性意见,你把action的method里换成方法名试试getData_From_Classes。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马