专注于 JetBrains IDEA 全家桶,永久激活,教程
持续更新 PyCharm,IDEA,WebStorm,PhpStorm,DataGrip,RubyMine,CLion,AppCode 永久激活教程

maven(整合Struts)

1、先新建一个Maven项目(在pom.xml中对struts进行配置):

   <dependency>
      <groupId>org.apache.struts</groupId>
      <artifactId>struts2-core</artifactId>
      <version>2.3.24</version>
    </dependency>

2、新建一个Action:

public class StudentAction extends ActionSupport {
    private Integer studentno;

    public Integer getStudentno() {
        return studentno;
    }

    public void setStudentno(Integer studentno) {
        this.studentno = studentno;
    }
    public String test(){
        System.out.println(studentno);
        return "success";
    }
}

3、在web.xml中配置过滤器:

  <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>

4、配置struts.xml配置文件:

<struts>
    <package name="student" namespace="/" extends="struts-default" >
        <action name="test" class="pers.zhb.action.StudentAction" method="test">
            <result name="success" >/info.jsp</result>
        </action>
    </package>
</struts>

5、定义提示页面:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>info</title>
    <h3>访问Action成功!!!!</h3>
</head>
<body>
</body>
</html>

6、项目结构:

84_1.png

7、测试:

浏览器:

84_2.png

控制台:

84_3.png

文章永久链接:https://tech.souyunku.com/23087

未经允许不得转载:搜云库技术团队 » maven(整合Struts)

JetBrains 全家桶,激活、破解、教程

提供 JetBrains 全家桶激活码、注册码、破解补丁下载及详细激活教程,支持 IntelliJ IDEA、PyCharm、WebStorm 等工具的永久激活。无论是破解教程,还是最新激活码,均可免费获得,帮助开发者解决常见激活问题,确保轻松破解并快速使用 JetBrains 软件。获取免费的破解补丁和激活码,快速解决激活难题,全面覆盖 2024/2025 版本!

联系我们联系我们