最近发现刚学过的知识忘得差不多了,写一写,记录一下。^_^
一、拷贝相关的jar包
二、拷贝applicationContext.xml和struts.xml文件到src文件夹下。
三、在web.xml文件中添加
四、编写LoginAction.java类
- package onlyfun.gray.action;
- import com.opensymphony.xwork2.ActionSupport;
- public class LoginAction extends ActionSupport {
- private String username;
- private String password;
- public String getUsername() {
- return username;
- }
- public void setUsername(String username) {
- this.username = username;
- }
- public String getPassword() {
- return password;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- @Override
- public String execute() throws Exception {
- // TODO Auto-generated method stub
- if(username.equalsIgnoreCase("gray") && password.equalsIgnoreCase("gray")) {
- return SUCCESS;
- }
- return INPUT;
- }
- }
五、在applicationContext.xml中添加
- <bean id="loginAction" class="onlyfun.gray.action.LoginAction"></bean>
六、在struts.xml中添加
- <!-- 配置struts.objectFactory属性值 -->
- <constant name="struts.objectFactory" value="spring"></constant>
- 和
- <action name="loginAction" class="loginAction">
- <result name="success">/success.jsp</result>
- <result name="input">/index.jsp</result>
- </action>
七、把应用程序发布到tomcat。