struts2学习一:搭建第一个struts2.5项目
2016-12-27 17:10
267 查看
在官网下载struts2.5.5的jar包,地址 http://struts.apache.org/download.cgi
使用tomcat7+1.7
打开eclipse,新建Dynamic Web Project
注意勾选Generate web.xml deployment descriptor
创建工程后,将下载到的相关jar包放入指定路径下,路径及具体jar文件参考下图
配置web.xml文件,简略如下图,注意红框内容,2.5版本与早期版本有所不同。
配置项目输出路径,项目上右键——属性——Java Build Path,设置下面的Default Output Folder为 {项目名称}/WebContent/WEB-INF/classes
在src路径下创建struts2.xml文件,并进行简单设置
设置项目属性——Server,选择相应的Tomcat。
设置Server
若Server Locations部分为灰色不能设置,则删除下面Server中tomcat下的项目并右键clean。
启动项目run on server,按照项目名称访问http://localhost:8080/struts2test/,报404错误
There is no Action mapped for namespace [/] and action name [] associated with context path [/struts2test].
需要在WebContent路径下创建index.html或其他在web.xml文件中设置的文件,如下
<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>index.action</welcome-file>
</welcome-file-list>
使用tomcat7+1.7
打开eclipse,新建Dynamic Web Project
注意勾选Generate web.xml deployment descriptor
创建工程后,将下载到的相关jar包放入指定路径下,路径及具体jar文件参考下图
配置web.xml文件,简略如下图,注意红框内容,2.5版本与早期版本有所不同。
配置项目输出路径,项目上右键——属性——Java Build Path,设置下面的Default Output Folder为 {项目名称}/WebContent/WEB-INF/classes
在src路径下创建struts2.xml文件,并进行简单设置
设置项目属性——Server,选择相应的Tomcat。
设置Server
若Server Locations部分为灰色不能设置,则删除下面Server中tomcat下的项目并右键clean。
启动项目run on server,按照项目名称访问http://localhost:8080/struts2test/,报404错误
There is no Action mapped for namespace [/] and action name [] associated with context path [/struts2test].
需要在WebContent路径下创建index.html或其他在web.xml文件中设置的文件,如下
<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>index.action</welcome-file>
</welcome-file-list>
相关文章推荐
- Struts2.0+Hibernate2.5+Spring3.0搭建JavaEE项目要用的jar
- Struts2学习(一)——第一个项目
- SSH与SSM学习之Struts201——介绍与环境搭建和第一个例子
- Struts2学习---用idea2017创建Struts项目
- springboot学习: 初识Spring Boot框架,搭建第一个项目!
- struts2小项目学习01之环境的搭建
- struts2入门-第一个例子==》第一个struts2实例——HelloWorld==》Struts2.0搭建和简单实例==>写一个Steuts2的经典入门案例,做了一个登陆程序作为入门例子
- IDEA Struts学习项目搭建[初学者一目了然]
- JavaWeb学习之SpringMVC:MAVEN搭建第一个WEB项目
- python+Django+pycharm+mysql 环境搭建及第一个项目学习笔记
- struts2开发环境的搭建与第一个项目的创建
- django 第一个项目-学习搭建博客 (四、Django url 和视图)
- Cocos2d-x学习(二) 在Cocos2d-x2.2.6搭建你第一个项目
- Struts2学习(一)【介绍与环境搭建和第一个例子】
- 传智播客struts2学习笔记(一) struts2的初步认识及第一个struts应用
- C++学习笔记1C++开发环境搭建创建第一个项目Hello word!
- django 第一个项目-学习搭建博客 (二、Django模型)
- django 第一个项目-学习搭建博客 (三、Django admin 管理后台)
- springboot学习: 初识Spring Boot框架,搭建第一个项目!
- [Struts2 框架学习] Struts2.5 通配符动态方法调用问题