eclipse学习(第二章:初识ssh)——7.struts2的结果类型(重定向与转发)
前言
我是从这个网站学习的
https://www.w3cschool.cn/struts_2/struts_result_types.html
创建一个项目工程
1.初始化项目以及导入相关jar包
2.创建一个action处理类
创建ActionSupport ,用来处理访问逻辑
package com.czx.result;
import com.opensymphony.xwork2.ActionSupport;
public class HiAction extends ActionSupport {
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
private String username;
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
return "success";
}
}
3.修改web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>ssh_learn_intercept</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.