struts spring + hibernate整合问题

cs_kill_you 2008-04-12 11:27:08



我的struts + spring + hiberante整合有问题,谁能帮我看看,我是这样整合的
struts-config.xml

<struts-config>
<data-sources />
<form-beans>
<form-bean name="loginForm"
type="com.chinamobile.struts.form.LoginForm" />
</form-beans>
<global-exceptions />
<global-forwards />
<action-mappings>
<action attribute="loginForm" input="/login.jsp"
name="loginForm" path="/login" scope="request"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="success" path="/admin/index.jsp" />
<forward name="failure" path="/index.jsp"></forward>
</action>
</action-mappings>
<message-resources parameter="com.chinamobile.struts.ApplicationResources" />

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



bena.xml

<bean name="/login" class="com.chinamobile.struts.action.LoginAction">
<property name="ioperator">
<ref bean="ioperatorimpl"/>
</property>
</bean>
...全文
76 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuxiang19840814 2008-04-30
  • 打赏
  • 举报
回复
包是不是不对呀
cs_kill_you 2008-04-14
  • 打赏
  • 举报
回复
对不起,我改一下,说清楚一点.


我的myeclipse6.0整合SSH怎么么都是不成功的啊,用myeclipse5.0就不问题,都是一模一样的整合,怎么就不行呢,别人的就行,我是这样整合的,帮我看看错在哪,它提示的是404错误,

HTTP Status 404 - Servlet action is not available
The requested resource (Servlet action is not available) is not available.



我的 web.xml 是这样的

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.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>
<welcome-file-list>
<welcome-file>index.jsp </welcome-file>
</welcome-file-list>
</web-app>


jsp页面是这样的 test.jsp

<%@ page language="java" pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>test.jsp </title>
</head>

<body>
<form action="test.do" method="post">
login: <input type="test" name="login"> <br>
password: <input type="text" name="password"> <br>
<input type="submit">
</form>
</body>
</html>

TestAction.java是这样的


public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
TestForm testForm = (TestForm) form;// TODO Auto-generated method stub
return mapping.findForward("success");
}

struts-config.xml是这样的

<?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="testForm" type="com.one.struts.form.TestForm" />

</form-beans>

<global-exceptions />
<global-forwards />
<action-mappings>
<action attribute="testForm"
input="/test.jsp"
name="testForm"
path="/test"
scope="request"
parameter="method"
type="org.springframework.web.struts.DelegatingActionProxy">
<forward name="success" path="/success.jsp" />
</action>

</action-mappings>

<message-resources parameter="com.one.struts.ApplicationResources" />

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


beans.xml是这样的,省略了一部分数据源的配置

<bean name="/test" class="com.one.struts.action.TestAction"> </bean>


应该是这样整合吧,myeclipse5.0一点问题也没有.
minbing 2008-04-13
  • 打赏
  • 举报
回复
spring与hibernate整合的xml文档哪去了?要以插件的形式在Struts中,或在web.xml文档中以监听器的方式加载,最好选择后者。

67,538

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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