黑马程序员技术交流社区

标题: Strut2老是找不到action 代码如下,求解答 [打印本页]

作者: tei0513    时间: 2014-12-5 16:29
标题: Strut2老是找不到action 代码如下,求解答
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.


求解决方法



作者: stay_foolish    时间: 2014-12-5 16:29
第一,重启tomcat,重新部署项目
第二,只做建设性意见,你把action的method里换成方法名试试getData_From_Classes。




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2