欢迎来到天天文库
浏览记录
ID:40566443
大小:1.07 MB
页数:16页
时间:2019-08-04
《Struts1简单例子》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、修改字体大小:wiondow--preferences--general--appearance--colorsandfonts--java--javaeditortextfont然后点change,在弹出的框里选字号,然后确定就可以了~~预备知识:环境搭建:1.导入jar包2.配置文件struts-config.xml和web.xml介绍Østruts-config.xml:灵活配置Øweb.xml:ü注册Struts核心控制器——ActionServletüstruts-config.xml文件的位置配置s
2、ervletactionorg.apache.struts.action.ActionServletconfig/WEB-INF/struts-config.xml跟初始化相关的。指向struts-config.xml思考:
3、struts-config.xml可以改名吗?0在服务一启动就实例化action*.do一、一个简单的Struts应用1.开发Forml建立一个类,继承ActionForml在配置文件中注册该Form4、name="loginForm"type="my.example.LoginForm">2.开发Actionl建立一个类,继承Action覆盖execute方法publicActionForwardexecute(ActionMappingmapping,ActionFormform,HttpServletRequestrequest,HttpServletResponseresponse)throwsException{LoginFormloginForm=(
4、name="loginForm"type="my.example.LoginForm">
5、LoginForm)form;if(loginForm.getUsername().equals("mary"))returnmapping.findForward("loginSuccess");elsereturnmapping.findForward("loginFailure");}l在配置文件中注册该Action6、"loginSuccess"path="/LoginSuccess.jsp"/>3.JSP文件Login.jsp
6、"loginSuccess"path="/LoginSuccess.jsp"/>
7、sword:request.getContextPath()获取系统路径LoginFailure.jsp注意:execute方法的form参数execute方法:第一步:强制转型为ActionForm子类第二步:业务逻辑处理第三步:跳转login.jspUsernamePasswordaction=/login.dofront-end
8、control:ActionServletback-endcontrol:LoginAction是否成功loginsuccess.jsploginfailure.jspActionForm:LoginFormforwardkeywordsstruts-config.xml几次读取配置文件?如果配置文件里没有这个Action?试一试会怎样?将action-mapping内容删掉,看看错误
此文档下载收益归作者所有