日期:2014-05-19 浏览次数:20709 次
<?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"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:ctx="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
">
<!-- 配置Action -->
<bean id="index" class="com.am8.iner.action.LoginAction" scope="prototype"></bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
"http://struts.apache.org/dtds/struts-2.1.7.dtd">
<struts>
<constant name="struts.devMode" value="true"/>
<package name="configrue-pkg" extends="struts-default">
<action name="index" class="index">
<result name="success">/padding.jsp</result>
<result name="error">/error.jsp</result>
</action>
</package>
</struts>
package com.am8.iner.action;
import com.am8.iner.po.User;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport {
private User user;
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String execute(){
if(user.getName()!=null && user.getPassword()!=null){
return SUCCESS;
}
System.out.println("账号:"+user.getName()+"密码:"+user.getPassword());
return ERROR;
}
}
<body>
<form action="index" method="post">
测试数据:<input id="name" type="text" name="user.name" /><br /><br />
测试数据:<input id="password" type="password" name="user.password"/><br /><br />
<input type="submit" value="添加" />
</form>
</body>