用eclipse 搭建struts2环境

时间:2023-03-09 13:22:01
用eclipse 搭建struts2环境

一,下载struts2对应的jar包,(http://struts.apache.org/download.cgi#struts2514.1),我一般下载struts2.3版本的

用eclipse 搭建struts2环境用eclipse 搭建struts2环境

二,打开eclipse新建Dynamic Web Project

用eclipse 搭建struts2环境用eclipse 搭建struts2环境

用eclipse 搭建struts2环境

三、生成的项目文件夹如下

用eclipse 搭建struts2环境

四、配置各种文件(web.xml/struts.xml)

1.配置web.xml文件(项目一开始自动生成的文件,在WebContent/WEB-INF路径下)org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

用eclipse 搭建struts2环境

五、在Java Resourses 的src目录下创建的struts.xml文件,也可以直接从struts1\apps\struts2-blank\WEB-INF\classes 下的 struts.xml复制过来

用eclipse 搭建struts2环境

六、写java类

用eclipse 搭建struts2环境

七,写html页面(不喜欢写jsp,java语法跟html代码都混在一块了,前后端分离才是正道,个人观点)

用eclipse 搭建struts2环境用eclipse 搭建struts2环境

八,启动项目,看实际效果

用eclipse 搭建struts2环境

用eclipse 搭建struts2环境