您好,欢迎访问三七文档
达内IT培训集团1知识点列表编号名称描述级别1Struts2核心标记库掌握常用的几个核心标记的使用,熟练掌握在form表单中的操作***2拦截器的基本概念和配置理解Struts2中的拦截器概念,通过案例掌握拦截器的基本使用,以及掌握Struts2拦截器封装好的文件上传功能***注:*理解级别**掌握级别***应用级别达内IT培训集团2目录1.struts2核心标记库***....................................................................................................错误!未定义书签。1.1.知识点..................................................................................................................................................31.2.课堂案例............................................................................................................错误!未定义书签。2.struts2拦截器***............................................................................................................................................282.1.拦截器的基本概念和配置*.................................................................................................................28【案例2】拦截器**....................................................................................................................................32达内IT培训集团31.Struts2核心标记库***知识点1)UI标记常用UI标记a.formb.textfieldc.passwordd.submite.textareaf.checkboxg.radioh.selectStruts2标记a.通用属性(所有标记都具备的属性)注:带”*“星号的属性表示在任意主题,如xhtml下才可以使用label(*)labelposition(*)required(*)tooltip(*)tooltipIconPath(*)-------html原来的属性--------cssClass(html中的class)cssStyle(html中的sytle)namevalue....b.s:formformtheme主题namespace命名空间action达内IT培训集团4methodc.s:textfield&&s:passwordmaxLengthsizereadonlyd.s:textareacolsrowse.s:checkbox使用1个s:checkboxname=ok/查看页面源代码,我们会发现生成这样的htmlinputtype=checkboxname=okvalue=true/inputtype=hiddenname=_checkbox_okvalue=true/使用多个写在页面s:checkboxname=productfieldValue=1/s:checkboxname=productfieldValue=2/s:checkboxname=productfieldValue=3/劢态获得s:iteratorvalue=products!--products,Product类型的List--s:checkboxname=productfieldValue=%{id}//s:iteratorf.s:radio我们原来这么写inputtype=radioname=abcvalue=1/Oneinputtype=radioname=abcvalue=2/Twoinputtype=radioname=abcvalue=3/Three后来我们这么写s:radiolist=productOptionslabel=Radioname=abclistValue=labellistKey=value/属性含义:namelabellistOGNL--需要迭代的集合listValue作用于每一个选项的提示OGNL--listKey作用于每一个要提交的值OGNL--达内IT培训集团5g.selectselectname=abcoptionvalue=1One/optionoptionvalue=2Two/optionoptionvalue=3Three/option/selectStruts2标记s:selectlist=productOptionslabel=Selectname=abclistValue=labellistKey=value/属性含义:listValue对应每一个Option的文本listKey对应每一个Option提交的值headerValue提示头的文字headerKey提示头对应的提交值课堂案例【案例1】struts2核心标记库**项目结构图达内IT培训集团61)新建工程Struts042)配置好开发环境3)新建com.tarena.outman.BaseActionpackagecom.tarena.outman;importjava.util.Map;importjavax.servlet.ServletContext;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;importorg.apache.struts2.interceptor.ServletRequestAware;importorg.apache.struts2.interceptor.ServletResponseAware;importorg.apache.struts2.interceptor.SessionAware;importorg.apache.struts2.util.ServletContextAware;publicclassBaseActionimplementsSessionAware,ServletRequestAware,达内IT培训集团7ServletResponseAware,ServletContextAware{protectedMapString,Objectsession;protectedHttpServletRequestrequest;protectedHttpServletResponseresponse;protectedServletContextapplication;publicvoidsetSession(MapString,Objectsession){this.session=session;}publicvoidsetServletRequest(HttpServletRequestrequest){this.request=request;}publicvoidsetServletResponse(HttpServletResponseresponse){this.response=response;}publicvoidsetServletContext(ServletContextcontext){this.application=context;}}4)新建struts.xml?xmlversion=1.0encoding=UTF-8?!DOCTYPEstrutsPUBLIC-//ApacheSoftwareFoundation//DTDStrutsConfiguration2.1//EN=advanceextends=struts-defaultnamespace=/day04actionname=uitagclass=com.tarena.outman.day04.UITagActionmethod=formresultname=success/WEB-INF/jsp/day04/uitag.jsp/result/action/package/struts达内IT培训集团85)新建com.tarena.outman..day04.UITagActionpackagecom.tarena.outman.day04;importcom.tarena.outman.BaseAction;publicclassUITagActionextendsBaseAction{publicStringform(){returnsuccess;}}s:formtheme属性6)新建uitag.jsp%@pagepageEncoding=utf-8%%@tagliburi=/struts-tagsprefix=s%htmlheadtitle/title/headbodys:formaction=method=theme=xhtmls:textfieldlabel=username/s:passwordlabel=password/s:submit//s:form/body/htmltheme属性:表示主题,可选项有xhtml和simple;如果丌写,默认为xhtml7)访问会自劢加样式达内IT培训集团9查看页面源代码,我们知道,struts2为form自劢添加了table表格,让显示更好看些(略)8)修改uitag.jsp%@pagepageEncoding=utf-8%%@tagliburi=/struts-tagsprefix=s%htmlheadtitle/title/headbodys:formaction=method=theme=simples:textfieldlabel=username/s:passwordlabel=password/s:submit//s:form/body/html9)访问原样显示,simple类型注:在theme=simple下,label丌起作用了达内IT培训集团10struts2s:form标签可以自动将Action的属性填写到页面form表单中(注:密码是丌被自劢填写的)10)修改UITagActionpackagecom.tarena.outman.day04;importcom.tarena.outman.BaseAction;publicclassUITagActionextendsBaseAction
本文标题:达内培训tarena内部资料tts教学系统课件pdf版java_struts_day04
链接地址:https://www.777doc.com/doc-6365692 .html