`

Struts框架开发过程记录

 
阅读更多
1.下载struts2的所有文件
2.创建项目导入jar包
3.简单的登陆页面login.jsp
4.只有一个action,LoginAction
5.写struts.xml配置文件,配置action
6.在web.xml中配置struts2
第一个遇到的问题:发现服务器启动不了报错:not defind strut-default.xml
答:导入的jar版本和
<filter>
  <filter-name>struts2</filter-name>
  <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
 
  </filter>
这里jar包要和这个过滤对应,本次用的是struts2-code-2.3.19.jar版本,
第二个问题:发现找不到commons-lang3.jar原来我导入的是commons-lang2.jar所有换,然后启动项目。一切OK。


7.运行该项目没有出错,成功转到welcome.jsp。失败转到error.jsp
8.扩充项目,action继承ActionSupportaction中加入validate方法,来验证输入的用户名和密码。不正确则返回提示的错误信息。顺利通过。
9.加入国际化信息,加入book_zh_CN.properties;在struts.properties中配置国际化信息文件,但是没有成功,寻找答案:原来是在struts.xml中没有配置,加入配置
<constant name="struts.custom.i18n.resources" value="book"></constant> 成功实现。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics