[Java] Structs

背景

  • 基于MVC的WEB框架 
  • 在表示层过滤访问请求并处理

步骤

  • 在eclipse中创建Web动态项目
  • 导入相关jar包到WEB-INF/lib
  • 在WEB-INF目录下新建web.xml,配置Filter
    • org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
  • 在src目录下创建struts.xml文件
    • <actionname="index">
    • <result>index.jsp</result>
    • </action>
    • 实现了当访问index路径的时候,服务端跳转到index.jsp
  • web目录下创建index.jsp
  • 重启重启tomcat,访问 http://127.0.0.1:8080/struts/index

原文地址:https://www.cnblogs.com/cxc1357/p/12518099.html