日期:2014-05-17  浏览次数:20633 次

SSH整合问题 求高手解决
我用的是MyEclipse8.6+tomcat7
做的是struts2.1 + spring2.5 + hibernate3整合的小例子 ,用来练习。
添加的 所有支持均是myEclipse的可视化工具完成的。

login.jsp:
HTML code

<form action="<%=request.getContextPath() %>/login.action">
用户名:<input name="stu.stuName"><br>
密码:<input name="stu.stuPwd"><br>
<input type="submit" value="submit">
</form>



web.xml:
XML code

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <welcome-file-list>
    <welcome-file>login.jsp</welcome-file>
  </welcome-file-list>
  <filter>
      <filter-name>struts2</filter-name>
      <filter-class>
          org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
      </filter-class>
  </filter>
  <filter-mapping>
      <filter-name>struts2</filter-name>
      <url-pattern>/*</url-pattern>
  </filter-mapping>
  
  <listener>
     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  <context-param>
     <param-name>contextConfigLocation</param-name>
     <param-value>classpath:applicationContext.xml</param-value>
  </context-param>
 </web-app>




struts.xml:
XML code

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<package name="suibiaojiao" extends="struts-default">
   <action name="login" class="loginAction">
      <result name="ok">/ok.jsp</result>
      <result name="error">/error.jsp</result>
   </action>
   
</package>
</struts>  



applicationContext.xml:
XML code

<?xml version="1.0" encoding="UTF-8"?>
<beans
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
    
    <bean id="dataSource"
        class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName"
            value="com.mysql.jdbc.Driver">
        </property>
        <property name="url" value="jdbc:mysql://127.0.0.1:3306"></property>
        <property name="username" value="root"></property>
        <property name="password" value="lm"></property>
    </be