版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38749759/article/details/89080890
Action的定义
定义一个类继承Action
覆盖Action的execute
例
在写loginAction.java时一定要检查是否配置好了Tomcat,否则会报错
Action的声明
配置在struts-config.xml文件里
例
Web.xml
Action的调用方法之一【表单调用】
Login.jsp
struts-config
Web.xml
em……………写的比较简陋,不要见怪!
运行效果
登陆前
登陆后
遇见问题:
1.如果运行时出现404-----重新启动Tomcat
2.如果运行时出现500-----检查文件(web.xml,struts-config.xml)
#常见的错误#
#web.xml中servlet-class 的内容写错或不全,struts-config.xml,没有正确的引用
#struts-config.xml 中的action path与jsp的action不一致
===============================================================================
全部代码(用eclipse,导入一下项目,添加服务器,并设置一下java build path,即可使用)
链接:https://pan.baidu.com/s/1cazuocYqe4mArMbNPTgneg
提取码:3tpf
复制这段内容后打开百度网盘手机App,操作更方便哦