action
常用配置文件
docs目录:官方文档
lib 目录:存放所有类库jar文件
Src 目录:源码
进入 struts-2.1.6\apps\struts2-blank-2.1.6\WEB-INF 下:
a) 复制struts.xml文件。classes下面的struts.xml,拷到web工程的src下面,因为工程编译完它默认就把src下的文件放到class文件下面。
<struts>
<!-- <constant> 常量的配置。 -->
<!-- name="struts.devMode" value="true" 开发模式改为true之后,修改配置文件可以马上生效,不用重启服务器。 -->
<constant name="struts.devMode" value="true" />
<package name="default" namespace="/" extends="struts-default">
<action name="hello">
<result>/hello.jsp</result>
</action>
</package>
</struts>
http://localhost:8080/strust2_0100_Introduction/[U1]
http://localhost:8080/strust2_0100_Introduction/hello 或者
http://localhost:8080/strust2_0100_Introduction/hello.action[U2]
[U1]这里的“/”对应namespace的“/”,因为action 的name属性为hello,所以敲
[U2]默认的aciton是可以省略的
b) 复制类库。lib下面的jar文件,需要除junit和spring-test之外的所有文件,其中commons-io的jar包会在文件上传和下载时需要,其他为必须。(把jar放入lib后看不见jar文件,是因为MyEclipse默认视图是package Explorer,如果要看硬盘上对应的视图,应该打开[windows] [Show View] [other] [navigatior])
struts2-core-2.1.6.jar :开发的核心类库
freemarker-2.3.13.jar :struts2的UI标签的模板使用freemarker编写
commons-logging-1.0.4.jar :日志包
ognl-2.6.11.jar :对象图导航语言,通过它来读写对象属性
xwork-2.1.2.jar :xwork类库,struts2在其上进行构建
commons-fileupload-1.2.1.jar:文件上传组件,2.1.6版本后必须加入此jar包
c) 配置web.xml。复制web.xml的filter 和filter-mapping,到web工程的web.xml中。
<filter>