5 Web应用开发

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

3Sept.2008©NeusoftConfidentialCopyright2008ByNeusoftGroup.AllrightsreservedJAVAWEB——WebIT3Sept.2008ConfidentialWEB3Sept.2008Confidential•Web•MVCWeb•Web••Filter3Sept.2008ConfidentialWeb3Sept.2008Confidential——HTTPWebAWebB•3Sept.2008ConfidentialHttp•HTTPURL,URLHTTPGet•HTTP–HttpServletResponse•sendRedirect(Stringlocation)–location•URL•URL“/”URI3Sept.2008Confidential•forwardWebAWebBBrowserBrowser3Sept.2008ConfidentialRequestDispatcher•(RequestDispatcher)–Web–Web•RequestDispatcher–forward(ServletRequestreq,ServletResponseres)•WebWeb3Sept.2008ConfidentialRequestDispatcher•RequestDispatcher–ServletContext•getRequestDispatcher(Stringpath)•path“/”WebContextRoot–ServletRequest•getRequestDispatcher(Stringpath)•pathWeb“/”Contextroot3Sept.2008Confidential•Servlet3Sept.2008Confidential•–HttpServletResponse.sendRedirect(Stringurl)–RequestDispatcher.forward(……)•–WebAWebB•––•3Sept.2008Confidential•includeWebAWebB3Sept.2008Confidentialinclude•RequestDispatcher–include(ServletRequestreq,ServletResponseres)•Web3Sept.2008ConfidentialJSP•JSP–Scriptlet•XML–jsp:action[attr=”value”]*……/jsp:action–jsp:action[attr=”value”]*/•action–includeforwardparam–useBeangetPropertysetProperty3Sept.2008ConfidentialJSP•–jsp:forwardpage=“navigation.jsp”/•–WebRequestDispatcher.forward–•page–page=“URI”–“/”contextrootURLJSPURI•3Sept.2008ConfidentialJSPinclude•jsp:include–jsp:includepage=“navigation.jsp”flush=“true”/•–Web,RequestDispatcher.include•–forward3Sept.2008Confidentialjsp:param•–jsp:forwardpage=“next”jsp:paramname=“role”value=“admin”//jsp:forward•––•includeforward••–name–value3Sept.2008Confidentialinclude•–%@includefile=“navigation.jsp”%•–JSPfile•file–3Sept.2008ConfidentialMVCWebMVC3Sept.2008ConfidentialMVCWeb•MVC–MVC––MVC–3Sept.2008Confidential•()()()3Sept.2008Confidential3Sept.2008ConfidentialMVC3Sept.2008ConfidentialMVC•Controller–ServletJava•View–JSP+•Model–Java–EJB–Hibernate()3Sept.2008ConfidentialMVCWeb3Sept.2008ConfidentialMVC•MVC–M–V•3Sept.2008ConfidentialMVCWebWeb3Sept.2008Confidential•ServletRequest–setAttribute(Stringname,Objectobject)–getAttribute(Stringname):Object–removeAttribute(Stringname)–getAttributeNames():Enumeration3Sept.2008Confidential•–request.sendRedirect(“…/welcome.jsp?userName=ZhangSan”);3Sept.2008Confidential•––3Sept.2008ConfidentialWeb3Sept.2008ConfidentialWeb•Web–HTTP•–Servlet•HTTP5003Sept.2008ConfidentialHttp•DDHTTP•error-pageerror-code404/error-codelocation/error/404.jsp/location/error-page•(error-code)HTTPWeb(location)Web3Sept.2008Confidential•DDservlet•error-pageexception-typejava.lang.Exception/exception-typelocation/error/exception.jsp/location/error-page3Sept.2008ConfidentialWeb•WebServlet(exception-type)–URIkey•“javax.servlet.error.exception”•“javax.servlet.error.request_uri”–locationWeb3Sept.2008ConfidentialJSP•JSP–––•JSP–JSP_jspService_jspServiceWeb–3Sept.2008Confidential•/throws_error.jsppage–%@pageerrorPage=”error/ExceptionPage.jsp”%•/error/ExceptionPage.jsppage–%@pageisErrorPage=”true”%•3Sept.2008ConfidentialPage•pageerrorPage–JSP–errorPage=“URL”•URL“/”contextrootURLJSPURL•pageisErrorPage–JSPJSP–truefalse–trueexception3Sept.2008Confidential3Sept.2008Confidential•JDBC––––statement–SQL––ResultSetStatementConnection3Sept.2008Confidential•–javax.sql.DataSource•getConnection():Connection–•DataSource––•3Sept.2008Confidential•–-()•JNDI–Context•lookup(StringjndiName):Object3Sept.2008ConfidentialTomcatDataSource•Web–META-INF/context.xml•Context/Resource–name•Contextcontext=newInitalContext();DataSourceds=(DataSource)context.lookup(“java:comp/env/jndiName”);Connectionconn=ds.getConnection();3Sept.2008Confidential•–3Sept.2008Confidential•–JDBC–JDBC–JNDI3Sept.2008ConfidentialFilter3Sept.2008ConfidentialFilter()•Filter3Sept.2008ConfidentialFilter•FilterChain3Sept.2008ConfidentialFilter•FilerMapping3Sept.2008ConfidentialFilterfilterfilter-namesetcharencoding/filter-namefilter-classorg.training.course.filter.setCharEncoding/filter-class/filterfilter-mappingfilter-namesetcharencoding/filter-nameurl-pattern/*/url-pattern/filter-mapping3Sept.2008ConfidentialFilter•javax.servlet.Filter–init(FilterConfigconfig)–doFilter(ServletRequestrequest,ServletResponseresponse,FilterChainchain)–destroy()•javax.servlet.FilterChain–doFilter(ServletRequestrequest,ServletResponseresponse)3Sept.2008Confidential•MVC•Http•3Sept.2008ConfidentialCopyright©2008

1 / 53
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功