一个SSH结构的一对多问题【菜鸟提问】请大家帮帮忙急。。。。。

sea_moon40 2008-03-22 11:30:36
页面错误:HTTP Status 404 - Servlet action is not available

后台没有提示错误


web.xml
<?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"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<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>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate.support.OpenSessionInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<!--
tomcat 5.5 不能用
启动报error: org.apache.catalina.core.standardcontext start
严重: error listenerstart
<listener>
<listener-class>org.springframework.web.context.ContextLoader.Lise</listener-class>
</listener>
-->
<welcome-file-list>
<welcome-file>index.do</welcome-file>
</welcome-file-list>
<jsp-config>
<!-- jstl -->
<taglib>
<taglib-uri>/WEB-INF/c-1_0-rt.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/c-1_0-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/fmt-1_0-rt.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/fmt-1_0-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/sql-1_0-rt.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/sql-1_0-rt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/x-1_0-rt.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/x-1_0-rt.tld</taglib-location>
</taglib>
<!-- struts -->
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>
/WEB-INF/tld/struts-html.tld
</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>
/WEB-INF/tld/struts-bean.tld
</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>
/WEB-INF/tld/struts-logic.tld
</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
<taglib-location>
/WEB-INF/tld/struts-nested.tld
</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/tld/struts-tiles.tld</taglib-uri>
<taglib-location>
/WEB-INF/tld/struts-tiles.tld
</taglib-location>
</taglib>
</jsp-config>
</web-app>

struts-config.xml

<?xml version="1.0" encoding="GBK"?>
<!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>
<form-beans>

</form-beans>
<!-- Action Mapping Definitions -->

<action-mappings>
<action path="/index" >
<forward name="net.newbss.ssh.index" path="/WEB-INF/jsp/index.jsp"></forward>
</action>
</action-mappings>


<controller inputForward="true" processorClass="org.springframework.web.struts.DelegatingRequestProcessor"/>
<message-resources
parameter="com.yourcompany.struts.ApplicationResources" />

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

applicationContext.xml

<?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="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="url" value="jdbc:mysql://localhost:3306/bbs"></property>
<property name="username" value="xxxxxx"></property>
<property name="password" value="xxxxxx"></property>
</bean>
<!-- session工厂 -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate.LocalSessionFactoryBean" destroy-method="close">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<!-- 映射文件位置 -->
<property name="mappingResources">
<list>
<value>net/newbbs/ssh/model/Group.hbm.xml</value>
<value>net/newbbs/ssh/model/Module.hbm.xml</value>
<value>net/newbbs/ssh/model/ChildModule.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
net.sf.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">
true
</prop>
</props>
</property>
</bean>
<!-- DAO 模板 -->
<bean id="dao" class="net.newbbs.ssh.dao.impl.BaseDAOHibernate">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 普通DAO配置集成 DAO模板 -->
<bean id="groupdao" class="net.newbbs.ssh.dao.impl.GroupDAOHibernate" parent="dao"></bean>
<bean id="moduledao" class="net.newbbs.ssh.dao.impl.ModuleDAOHibernate" parent="dao"></bean>
<bean id="childmoduledao" class="net.newbbs.ssh.dao.impl.ChildModulDAOHibernate" parent="dao"></bean>

<!-- 配置业务逻辑组建 -->
<bean id="foregroundManager" class="net.newbbs.ssh.service.impl.ForegroundManagerImpl">
<property name="groupDAO" ref="groupdao"></property>
<property name="moduleDAO" ref="moduledao"></property>
<property name="childModuleDAO" ref="childmoduledao"></property>
</bean>
<!-- 配置Hibernate管理 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 配置事务代理 -->
<bean id="txDAOProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager" ref="transactionManager"/>
<!-- 配置事务代理时,指定代理目标 此处为嵌套bean -->
<property name="target">
<ref local="foregroundManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
<bean name="/index" class="net.newbbs.ssh.action.indexAction">
<property name="foregroundManagerImpl" ref="foregroundManager"></property>
</bean>
</beans>



高手解答谢谢。。。
...全文
63 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
sea_moon40 2008-03-22
  • 打赏
  • 举报
回复
还有一点就是之间用程序调式没有问题。。可以显示出来
sea_moon40 2008-03-22
  • 打赏
  • 举报
回复
接上面
Module.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping package="net.newbbs.ssh.model">
<class name="Module" table="module">
<id
name="moduleId"
type="java.lang.Integer"
column="module_id"
>
<generator class="increment"/>
</id>

<property
name="moduleName"
column="module_name"
type="java.lang.String"
not-null="true"
/>
没有下面的话正常显示没有错误

<set name="childModule" inverse="true">
<key>
<column name="FK_parentModule_id"/>
</key>
<one-to-many class="ChildModule"/>
</set>
</class>
</hibernate-mapping>

Module.java
package net.newbbs.ssh.model;

import java.util.Set;

import org.apache.commons.lang.builder.ToStringBuilder;

@SuppressWarnings("serial")
public class Module extends BaseObject{

//define attribute
private int moduleId;
private String moduleName;
private Module module;
private Set childModule;

public Module(){

}
// IOC3 attribute
public Set getChildModule() {
return childModule;
}
public void setChildModule(Set childModule) {
this.childModule = childModule;
}
public Module getModule() {
return module;
}
public void setModule(Module module) {
this.module = module;
}
public int getModuleId() {
return moduleId;
}

public void setModuleId(int moduleId) {
this.moduleId = moduleId;
}
public String getModuleName() {
return moduleName;
}
public void setModuleName(String moduleName) {
this.moduleName = moduleName;
}

@Override
public boolean equals(Object obj) {
// TODO Auto-generated method stub
if (!(obj instanceof Module)) {
return false;
}
Module rhs=(Module)obj;
return this.module.getModule().equals(rhs.getModule());
}
public String toString() {
// TODO Auto-generated method stub
return new ToStringBuilder(this).append("moduleId",this.moduleId).append("moduleName",this.moduleName).toString();
}
}

81,115

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧