共计 622 个字符,预计需要花费 2 分钟才能阅读完成。
在 myeclipse 中实现 struts2 的登录例子
环境:myeclipse 6.0.1 GA
jdk:myeclipse 自带
tomcat:6.0
struts2:2.1.6
过程:
1、使用 myeclipse 建立 web 工程
2、由于在 struts2 中使用过滤器调用 action 的机制,所以需要在 web.xml 中添加过滤器代码
struts2
org.apache.struts2.dispatcher.FilterDispatcher
struts2
/*
3、将 struts2 的所需的 jar 拷到 lib 目录下
commons-logging-1.1.jar
freemarker-2.3.13.jar
ognl-2.6.11.jar
struts2-core-2.1.6.jar
xwork-2.1.2.jar
在许多教程中都写着,只要有以上 5 个 jar 包就可以了,但是我在使用中却不行,添加了 commons-fileupload-1.2.1.jar 这个 jar 包以后,才可以正确执行。
4、在 src 建立 struts.xml 文件,
http://struts.apache.org/dtds/struts-2.0.dtd
/result.jsp
5、建立 LoginAction 文件
6、建立 login.jsp 和 result.jsp 文件
7、发布
正文完