Spring + Sturts2 问题,Action调用失败
Sprint2.0 + Sturts2写了一个学习项目,用jsp调用struts action的时候老是不成功,这个问题困扰我一个多星期了,始终找不到原因。
下面是sturts.xml配置:
<struts>
<constant name="struts.custom.i18n.resources" value="messageResource"/>
<constant name="struts.i18n.encoding" value="GBK"/>
<include file ="struts-default.xml"/>
<package name="MyTest" extends="struts-default">
<action name="login" class="loginAction">
<result name="success">/ok.jsp</result>
<result name="login">/login.jsp</result>
</action>
</package>
</struts>
applicationContext.xml配置:
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.microsoft.jdbc.sqlserver.SQLServerDriver">
</property>
<property name="url"
value="jdbc:microsoft:sqlserver://EL040545:1433;DatabaseName=testdb">
</property>
<property name="username" value="sa"></property>
<property name="password" value="gpm7718"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>test/model/Person.hbm.xml</value>
</list>
</property>
</bean>
<bean id="personDao" class="test.dao.impl.PersonDAO">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="loginAction" class="test.action.LoginAction"
scope="prototype">
<property name="personDao">
<ref local="personDao"/>
</property>
</bean>
</beans>
调用action的login.jsp内容:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<s:form action="login" method="post">
<table width="40%" align="center">
<s:textfield label="username" name="username"/>
<s:password label="password" name="password"/>
<s:submit/>
</table>
</s:form>
</body>
</html>
运行环境是TOMCAT 6.0,启动应用的时候看到console输出都正常,spring, sturts,hibernate都加载正常,但是在点击login.jsp的submit按钮之后浏览器显示
HTTP Status 404 - /MyTest/login
--------------------------------------------------------------------------------
type Status report
message /MyTest/login
description The requested resource (/MyTest/login) is not available.
Console上提示
2008-6-23 18:33:37 org.apache.struts2.components.Form evaluateExtraParamsServletRequest
警告: No configuration found for the specified action: 'login' in namespace: ''. Form action defaulting to 'action' attribute's literal value.
另外我debug发现程序根本没有执行LoginAction的execute方法
哪位高人能帮我一把!!这里先谢过了!