struts+spring+hibernate整合了一天了,还没成功

struts+spring+hibernate整合了一天了,还没成功,请各位看看,哪里不对了

错误提示如下:

[code]HTTP Status 404 - Servlet action is not available

type Status report

message Servlet action is not available

description The requested resource (Servlet action is not available) is not available.
Apache Tomcat/5.5.23[/code]

struts-config.xml文件如下:
[code]<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>
<data-sources />
<form-beans >
<form-bean name="findUserForm" type="org.xredleaf.form.FindUserForm" />

</form-beans>

<global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="findUserForm"
input="/form/findUser.jsp"
name="findUserForm"
path="/findUser"
scope="request"
validate="true"

/>

</action-mappings>

<message-resources parameter="org.xredleaf.ApplicationResources" />

<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml" />
</plug-in>

</struts-config> [/code]

applicationContext.xml 文件如下:
[code]<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
<bean id="DataSoure"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName">
<value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
</property>
<property name="url">
<value>jdbc:microsoft:sqlserver://localhost:1433</value>
</property>
<property name="username">
<value>sa</value>
</property>
<property name="password">
<value>123456</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="DataSoure" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>org/xredleaf/dao/Sysuser.hbm.xml</value>
</list>
</property>
</bean>
<bean id="SysuserDAO" class="org.xredleaf.dao.SysuserDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>

<bean name="/findUser" class="org.xredleaf.action.FindUserAction" singleton="false">
<property name="dao">
<ref bean="SysuserDAO"/>
</property>
</bean>

</beans>[/code]

SysuserDAO.java内容如下:

[code]package org.xredleaf.dao;

import java.util.Date;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
* Data access object (DAO) for domain model class Sysuser.
* @see org.xredleaf.dao.Sysuser
* @author MyEclipse - Hibernate Tools
*/
public class SysuserDAO extends HibernateDaoSupport {

private static final Log log = LogFactory.getLog(SysuserDAO.class);

//property constants
public static final String USERNAME = "username";
public static final String PASSWORD = "password";
public static final String TYPE = "type";

protected void initDao() {
//do nothing
}

public void SysuserDAO(){
log.debug("init SysuserDAO");
}
public void save(Sysuser transientInstance) {
log.debug("saving Sysuser instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;
}
}

public void delete(Sysuser persistentInstance) {
log.debug("deleting Sysuser instance");
try {
getHibernateTemplate().delete(persistentInstance);
log.debug("delete successful");
} catch (RuntimeException re) {
log.error("delete failed", re);
throw re;
}
}

public Sysuser findById( java.lang.Integer id) {
log.debug("getting Sysuser instance with id: " + id);
try {
Sysuser instance = (Sysuser) getHibernateTemplate()
.get("org.xredleaf.pojo.Sysuser", id);
return instance;
} catch (RuntimeException re) {
log.error("get failed", re);
throw re;
}
}


public List findByExample(Sysuser instance) {
log.debug("finding Sysuser instance by example");
try {
List results = getHibernateTemplate().findByExample(instance);
log.debug("find by example successful, result size: " + results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}

public List findByProperty(String propertyName, Object value) {
log.debug("finding Sysuser instance with property: " + propertyName
+ ", value: " + value);
try {
String queryString = "from Sysuser as model where model."
+ propertyName + "= ?";
return getHibernateTemplate().find(queryString, value);
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}

public List findByUsername(Object username) {
return findByProperty(USERNAME, username);
}

public List findByPassword(Object password) {
return findByProperty(PASSWORD, password);
}

public List findByType(Object type) {
return findByProperty(TYPE, type);
}

public Sysuser merge(Sysuser detachedInstance) {
log.debug("merging Sysuser instance");
try {
Sysuser result = (Sysuser) getHibernateTemplate()
.merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}

public void attachDirty(Sysuser instance) {
log.debug("attaching dirty Sysuser instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}

public void attachClean(Sysuser instance) {
log.debug("attaching clean Sysuser instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}

public static SysuserDAO getFromApplicationContext(ApplicationContext ctx) {
return (SysuserDAO) ctx.getBean("SysuserDAO");
}
}[/code]

FindUserAction.java内容如下:

[code]/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package org.xredleaf.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.xredleaf.dao.Sysuser;
import org.xredleaf.dao.SysuserDAO;
import org.xredleaf.form.FindUserForm;

/**
* MyEclipse Struts
* Creation date: 08-15-2007
*
* XDoclet definition:
* @struts.action path="/findUser" name="findUserForm" input="/form/findUser.jsp" scope="request" validate="true"
*/
public class FindUserAction extends Action {

private static final Log log = LogFactory.getLog(FindUserAction.class);
private SysuserDAO dao;

public FindUserAction(){
log.debug("init FindUserAction");
}
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
log.debug("start...");
FindUserForm findUserForm = (FindUserForm) form;

List list = dao.getHibernateTemplate().loadAll(Sysuser.class);
//dao=(SysuserDAO)getBean("SysuserDAO");

log.debug(list.size());
return null;
}

public void setDao(SysuserDAO dao){
this.dao=dao;
}

public SysuserDAO getDao(){
return dao;
}



}[/code]


web.xml配置如下:

[code]<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>[/code]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值