springmvc day02高級參數(shù)圖片json數(shù)據(jù)交互工程第二天課堂筆記_第1頁
springmvc day02高級參數(shù)圖片json數(shù)據(jù)交互工程第二天課堂筆記_第2頁
springmvc day02高級參數(shù)圖片json數(shù)據(jù)交互工程第二天課堂筆記_第3頁
springmvc day02高級參數(shù)圖片json數(shù)據(jù)交互工程第二天課堂筆記_第4頁
springmvc day02高級參數(shù)圖片json數(shù)據(jù)交互工程第二天課堂筆記_第5頁
已閱讀5頁,還剩13頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)

文檔簡介

Jsp@parampublicStringqueryItem(QueryVovo,Integer[]ids){if(ids!=null&&ids.length>0)for(Integerid:ids)System.out.println("傳入的商品列表分別為:}}return}ListJspPOJO@RequestMap可以加在類頭部,用于 redirect@authorpublicclassCustomerExceptionimplementsHandlerExceptionResolverpublicModelAndViewresolveException(HttpServletRequestrequest,HttpServletResponseresponse,Objecthanlder,Exceptione)Stringmsg很抱歉,系統(tǒng)發(fā)生異常了,請聯(lián)系管理員ModelAndViewmav=newmav.addObject("msg"msg);returnmav;}}測試@authorpublicclassMyExceptionextendsExceptionprivateStringpublicMyException()}publicMyException(Stringmsg)this.msg=msg;}publicStringgetMsg()return}publicvoidsetMsg(Stringmsg)this.msg=}}測試 加入上能需要的jar配置多解析<!--配置多處理器--<bean <propertyname="maxUploadSize" "jsp編寫上傳處理代@RequestMap(value="updateItem",method{RequestMethod.POST,RequestMethod.GETpublicStringupdateItem(Itemitem,Modelmodel,MultipartFilepicFile)throwsException{//新名Stringname=//原名StringoldName=StringexeName=Filepic=newFile("D:\\WebWork\\"+name+//保存到本地磁//更新商品信item.setPic(name+model.addAttribute("item",item);model.addAttribute("msg"修改商品成功");return"itemEdit";}jsonjar*@parampublicItemgetItem(@RequestBodyItemitem2){System.out.println("接收到的json商品數(shù)據(jù)為:item2);Itemitem=return}測試,安裝瀏覽器測試工Springmvc@param@parampublicStringtestRest(@PathVariable("id")Integerids,Modelmodel){Itemitem=itemServices.getItemById(ids);model.addAttribute("item",item);return}測試直接url{項目名/item/1.action}即可99.1器開發(fā)流創(chuàng)建一號@authorpublicclassMyInterceptor1implementsHandlerInterceptorpublicvoid pletion(HttpServletRequestarg0,HttpServletResponsearg1,Objectarg2,Exceptionarg3)throwsException }publicvoidpostHandle(HttpServletRequestarg0,HttpServletResponsearg1,Objectarg2,ModelAndViewarg3)throwsException{ }publicbooleanpreHandle(HttpServletRequestarg0,HttpServletResponsearg1,Objectarg2)throwsException{ return}}二號器,一號,修改一下系統(tǒng)輸出消配置<!--器定義--<!--定義一個器--<!--path配置</**>所有請求,包括二級以上 <mvc:mapclass="erceptor.MyInterceptor1"/><!--定義一個器--<!--path配置</**>所有請求,包括二級以上 <mvc:mapclass="erceptor.MyInterceptor2"/>9.2器案例應(yīng)用,登錄session3、器 <%@pagelanguage="java"contentType="text/html;charset=UTF-<!DOCTYPEhtmlPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"""><metahttp-equiv="Content-Type"content="text/html;charset=UTF-<formaction="${pageContext.request.contextPath用戶名:<inputtype="textname="username:<inputtype="password"name="password"<input登錄@authorpublicclassUserControllerpublicStringtoLogin(){return}publicStringlogin(Stringusername,Stringpassword,HttpSessionStringresult=if(username!=result=}return}}publicbooleanpreHandle(HttpServletRequestrequest,HttpServletResponseresponse,Objectarg2)throwsException{Objectattribute=if(attribute!=returnresponse.sendRedirect(request.getContextPath()+r

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論