JavaWeb开发5

JavaWeb开发5

ID:40226442

大小:887.50 KB

页数:112页

时间:2019-07-27

JavaWeb开发5_第1页
JavaWeb开发5_第2页
JavaWeb开发5_第3页
JavaWeb开发5_第4页
JavaWeb开发5_第5页
资源描述:

《JavaWeb开发5》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、JavaWeb开发计算机系孙杰JSP/Servlet深入编程5本章内容1.Servlet过滤器2.Servlet监听器3.JSP与JavaScript4.JSP表单问题5.JSP文件操作和下载上传6.JSP读取CheckBox的值7.JDBC与设计模式5.1Servlet过滤器什么是Servlet过滤器(过滤器作用和登录验证的流程)过滤器的用法过滤器的编程结构过滤器的典型应用JSP/Servlet的汉字问题登录验证5.1.1Servlet过滤器一种特定类型的Servlet,能够拦截请求和响应,可以过滤到

2、客户机和服务器之间交换的数据过滤器介于浏览器和需要过滤的JSP、Servlet之间过滤器能够接受请求响应,然后可以检查请求对象的内容,并根据情况将请求转发给下一个组件,或者中止这次请求并返回给浏览器通过过滤器,对请求提交的数据统一进行编码转换,可以一次性编码解决汉字问题5.1.2Servlet过滤器用法建立一个实现Filter接口的类,这个类需要实现3个方法:doFilter,init,destroy在doFilter方法中进行过滤操作,这个方法中包含ServletRequest和ServletRespo

3、nse两个对象调用FilterChain对象中的doFilter方法,进行请求的传递在web.xml配置文件中,对需要过滤的资源进行设置5.1.3Servlet过滤器编程结构1.需要引入的包importjavax.servlet.*;importjavax.servlet.http.*;2.实现接口FilterpublicclassCodeFilterimplementsFilter{…}3.设置过滤器属性FilterConfigprivateFilterConfigfilterConfig=null;S

4、ervlet过滤器编程结构4.doFilter方法publicvoiddoFilter(ServletRequestservletRequest,ServletResponseservletresponse,FilterChainchain)throwsIOException,ServletException{)5.init方法publicvoidinit(FilterConfigfilterConfig)throwsServletException{}6.destroy方法publicvoiddestr

5、oy(){this.filterConfig=null;}Servlet过滤器编程结构7.web.xml配置CodeFiltercom.sunjie.util.CodeFilterCodeFilter/view/*.jsp<

6、/filter-mapping>5.1.4过滤器—处理数据库汉字问题JSP的汉字问题的原理JSP的汉字问题出现环节JSP汉字问题的范围使用过滤器解决汉字问题JSP的汉字问题的原理客户端和服务器用gb2312HTTP传输编码用ISO8859_1服务器需要指示客户端文档的编码方式ISO8859_1ISO8859_1gb2312gb2312JSP的汉字问题出现环节客户端显示文档时的编码方式(由服务器中的JSP、Servlet指明)客户端发送汉字时自动转换为iso8859_1服务器中采用gb2312对汉字编码,接

7、收到客户端汉字需要转换为gb2312服务器端将JSP转换为Servlet时自动将汉字转换为iso8859_1服务器端应该告诉客户端汉字的编码方式JSP汉字问题的范围JSP、Servlet文件的汉字问题表单处理的汉字问题JDBC的汉字问题JSP文件的汉字问题JSP中的汉字字符串在服务器端用gb2312在编译为Servlet时自动转换为iso8859_1汉字在传输中是正确的在没有特别指示下,浏览器中无法正确显示在HTML中指示浏览器文档的编码(myJSPindex.html)

8、"Content-Type"content="text/html;charset=gb2312">在JSP中指示JSP引擎文档的编码<%@pagecontentType="text/html;charset=gb2312"%>每个要显示汉字的JSP文档都应该包含该语句JSP文件的汉字问题(JSPhanzi.jsp)<%--JSP的汉字问题JSPhanzi.jsp--%>JSP中的汉字问题<</p> </div> <div class="mt-3 bg-white"> <div class="d-lg-block d-none px-3 px-lg-4 py-3 border-bottom text-center font-18"> 当前文档最多预览五页,下载文档查看全文 </div> <div class="detail-fixed-feature d-none d-lg-block" id="detailFixedFeatureBox"> <div class="px-3 px-lg-4 py-3 d-flex align-items-center justify-content-between fixed-feature-box" id="detailFixedFeature"> <div class="d-lg-flex d-none align-items-center"> <div> <a class="btn btn-outline-danger article-state" href="javascript:;" data-id="40226442" data-code="438274" data-title="JavaWeb开发5"> <span>侵权申诉</span> </a> <button type="button" class="btn btn-outline-secondary with-light ml-2" data-toggle="modal" data-target="#reportModal" data-id="40226442"><span>举报</span></button> </div> <nav class="d-flex align-items-center ml-4" id="anchorPoint"> <a href="javascript:;" class="btn btn-light anchor-pre px-2"><i class="iconfont text-muted"></i></a> <div class="text-muted mb-0 pre-point-list" id="prePointList"> <a class="px-2 active nav-link" href="#anchorImg0">1</a> <a class="px-2 nav-link" href="#anchorImg1">1</a> <a class="px-2 nav-link" href="#anchorImg2">2</a> <a class="px-2 nav-link" href="#anchorImg3">3</a> <a class="px-2 nav-link" href="#anchorImg4">4</a> <a class="px-2 nav-link" href="#anchorImg5">5</a> / <span class="px-2" id="prePageNums">112</span> </div> <a href="javascript:;" class="btn btn-light anchor-next px-2"><i class="iconfont text-muted"></i></a> </nav> </div> <div class="d-flex align-items-center"> <p class="d-lg-block d-none font-14 text-black-50 mb-0 mr-2">此文档下载收益归作者所有</p> <button class="btn btn-danger detail-download-btn px-3 ml-0 font-16" data-btn="downloadfile" style="width:128px;height:40px;" data-id="40226442" data-price="2000" data-size="887.50 KB" data-page="112页" data-type="ppt" data-binddown="true" data-isold="new_content" data-vip="0" data-title="JavaWeb开发5">下载文档</button> </div> </div> </div> </div> <div class="d-block d-lg-none px-3 px-lg-4 py-3 border-bottom text-center font-14" style="color:#999">当前文档最多预览五页,下载文档查看全文</div> <button class="btn d-block w-100 d-lg-none btn-danger detail-download-btn px-3 ml-0 font-16" data-btn="downloadfile" data-id="40226442" data-price="2000" data-size="887.50 KB" data-page="112页" data-type="ppt" data-binddown="true" data-isold="new_content" data-vip="0" data-title="JavaWeb开发5">点击下载本文档 </button> </div> <div class="px-3 px-lg-4 py-3 bg-white mt-3"> <ul class="nav custom-tab border-bottom" id="myTab" role="tablist"> <li class="nav-item" role="presentation"> <a class="nav-link active px-0 mr-4 font-16 font-weight-light pb-3" id="tips-tab" data-toggle="tab" href="#showTips" role="tab" aria-controls="showTips" aria-selected="true">版权提示</a> </li> <li class="nav-item" role="presentation"> <a class="nav-link px-0 pb-3 font-16 font-weight-light text-black-50" href="/d-40226442.html" >下载文档</a> </li> <dl class="flex-grow-1 mb-0 d-lg-none"> <li class="ml-3 float-right d-lg-none"> <button type="button" class="btn btn-light" data-toggle="modal" data-target="#reportModal" data-id="40226442"><span>举报</span></button> </li> </dl> </ul> <div class="tab-content with-content pt-3" id="myTabContent"> <div class="tab-pane fade show active font-14" id="showTips" role="tabpanel" aria-labelledby="showTips-tab"> 温馨提示: <br> 1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。<br> 2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。<br> 3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。<br> 4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。 <br> </div> </div> </div> </div> <div class="detail-sidebar d-none d-lg-block"> <div id="columnDetailSiderRight"> <div class="detail-yourlike mt-0 pb-2" id="relativeArticle"> <div class="border-bottom py-2 d-flex align-items-center justify-content-between"> <h5 class="font-16">相关文章</h5> <a class="font-14 hover-letter-spacing" href="/ucenter/search/index.html?text=JavaWeb开发5" target="_blank" rel="nofollow">更多<i class="iconfont font-12 pl-1"></i></a> </div> <ul class="font-14 like-list"> <li class=""> <a class="text-ellipsis office-icon text-dark office-icon-doc" href="/p-3815498.html" title="《javaweb开发技术》" target="_blank">《j<span class="text-danger">a</span><span class="text-danger">v</span><span class="text-danger">a</span>w<span class="text-danger">e</span><span class="text-danger">b</span><span class="text-danger">开</span><span class="text-danger">发</span>技术》</a> </li> <li class=""> <a class="text-ellipsis office-icon text-dark office-icon-doc" href="/p-8807983.html" title="eclipse配置javaweb开发" target="_blank"><span class="text-danger">e</span>clips<span class="text-danger">e</span>配置j<span class="text-danger">a</span><span class="text-danger">v</span><span class="text-danger">a</span>w<span class="text-danger">e</span><span class="text-danger">b</span><span class="text-danger">开</span><span class="text-danger">发</span></a> </li> <li class=""> <a class="text-ellipsis office-icon text-dark office-icon-docx" href="/p-8968710.html" title="scwcd-ee5javaweb组件开发" target="_blank">scwcd-<span class="text-danger">e</span><span class="text-danger">e</span><span class="text-danger">5</span>j<span class="text-danger">a</span><span class="text-danger">v</span><span class="text-danger">a</span>w<span class="text-danger">e</span><span class="text-danger">b</span>组件<span class="text-danger">开</span><span class="text-danger">发</span></a> </li> <li class=""> <a class="text-ellipsis office-icon text-dark office-icon-docx" href="/p-8971944.html" title="javaweb项目开发总结" target="_blank">j<span class="text-danger">a</span><span class="text-danger">v</span><span class="text-danger">a</span>w<span class="text-danger">e</span><span class="text-danger">b</span>项目<span class="text-danger">开</span><span class="text-danger">发</span>总结</a> </li> <li class=""> <a class="text-ellipsis office-icon text-dark office-icon-doc" href="/p-9409788.html" title="javaweb开发学习笔记" target="_blank">j<span class="text-danger">a</span><span class="text-danger">v</span><span class="text-danger">a</span>w<span class="text-danger">e</span><span class="text-danger">b</span><span class="text-danger">开</span><span class="text-danger">发</span>学习笔记</a> </li> <li class=""> <a class="text-ellipsis office-icon text-dark office-icon-doc" href="/p-20760592.html" title="国外javaweb开发技术" target="_blank">国外j<span class="text-danger">a</span><span class="text-danger">v</span><span class="text-danger">a</span>w<span class="text-danger">e</span><span class="text-danger">b</span><span class="text-danger">开</span><span class="text-danger">发</span>技术</a> </li> <li class=""> <a class="text-ellipsis office-icon text-dark office-icon-ppt" href="/p-20792733.html" title="javaweb开发模型" target="_blank">j<span class="text-danger">a</span><span class="text-danger">v</span><span class="text-danger">a</span>w<span class="text-danger">e</span><span class="text-danger">b</span><span class="text-danger">开</span><span class="text-danger">发</span>模型</a> </li> <li class=""> <a class="text-ellipsis office-icon text-dark office-icon-doc" href="/p-27519793.html" title="javaweb开发技术试题" target="_blank">j<span class="text-danger">a</span><span class="text-danger">v</span><span class="text-danger">a</span>w<span class="text-danger">e</span><span class="text-danger">b</span><span class="text-danger">开</span><span class="text-danger">发</span>技术试题</a> </li> <li class=""> <a class="text-ellipsis office-icon text-dark office-icon-ppt" href="/p-36206179.html" title="javaweb开发概述" target="_blank">j<span class="text-danger">a</span><span class="text-danger">v</span><span class="text-danger">a</span>w<span class="text-danger">e</span><span class="text-danger">b</span><span class="text-danger">开</span><span class="text-danger">发</span>概述</a> </li> <li class=""> <a class="text-ellipsis office-icon text-dark office-icon-ppt" href="/p-40010896.html" title="《javaweb开发》ppt课件" target="_blank">《j<span class="text-danger">a</span><span class="text-danger">v</span><span class="text-danger">a</span>w<span class="text-danger">e</span><span class="text-danger">b</span><span class="text-danger">开</span><span class="text-danger">发</span>》ppt课件</a> </li> </ul> </div> <div class="detail-yourlike pb-2"> <div class="border-bottom py-2"> <h5 class="font-16">相关标签</h5> </div> <ul class="font-14 like-list d-flex flex-wrap"> <a class="search-tag" href="/tags/540156/" target="_blank">开发</a> </ul> </div> <script src="/d/js/acmsd/thea1.js"></script> </div> </div> </div> <footer> <div class="container d-none d-lg-block mb-4"> <div class="d-flex justify-content-between footer-nav"> <ul class="d-flex foot-nav"> <li> <h5>常见问题</h5> <a class=text-decoration-none href=/help/wenti/upload/ target=_blank> 关于上传 </a><a class=text-decoration-none href=/help/wenti/xiazai/ target=_blank> 关于下载 </a><a class=text-decoration-none href=/help/wenti/qinquan/ target=_blank> 关于侵权 </a><a class=text-decoration-none href=/help/wenti/fenxaing/ target=_blank> 分享文档赚钱教程 </a> </li> <li> <h5>关于我们</h5> <a class=text-decoration-none href=/help/about/wzjs/ target=_blank> 网站介绍 </a><a class=text-decoration-none href=/help/about/gywm/ target=_blank> 关于我们 </a><a class=text-decoration-none href=/help/about/lxwm/ target=_blank> 联系我们 </a> </li> <li> <h5>版权问题</h5> <a class=text-decoration-none href=/help/banquan/bqsm/ target=_blank> 版权声明 </a><a class=text-decoration-none href=/help/banquan/qqcl/ target=_blank> 侵权处理 </a><a class=text-decoration-none href=/help/banquan/mzsm/ target=_blank> 免责声明 </a> </li> <li> <h5>协议条款</h5> <a class=text-decoration-none href=/help/xieyi/yhxy/ target=_blank> 用户协议 </a><a class=text-decoration-none href=/help/xieyi/fwtk/ target=_blank> 用户服务条款 </a><a class=text-decoration-none href=/help/xieyi/ysbh/ target=_blank> 用户隐私保护 </a> </li> <li> <h5>网站导航</h5> <a class="text-decoration-none help-nav-item" href="/sitemaps.xml" data-name="网站地图" target="_blank">网站地图</a> <a class="text-decoration-none help-nav-item" href="/list.html" data-name="全部分类" target="_blank">全部分类</a> <a class="text-decoration-none help-nav-item" href="/sitemaps/index.html" data-name="资源地图" target="_blank">资源地图</a> </li> </ul> <div class="foot-qrcode d-flex"> <div> <div class="subsitute-bg"><img src="https://www.wenku365.com/d/file/2022/07-08/f23df57d987ef7ad9acb33fe5abf9854.jpg"></div> <p>关注公众号<br></p> </div> </div> </div> </div> <div class="footer-copyright"> <p><a href="/" target="_blank">天天文库</a>站为“文档C2C交易模式”,即用户上传的文档直接卖给(下载)用户,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有【成交的100%(原创)】。</p> <p>本站是网络服务平台方,若您的权利被侵害,侵权客服QQ:3074922707 欢迎举报。</p> <p>Copyright 2004-2021 <a href="https://www.wenku365.com/" target="_blank">wenku365.com</a> All Rights Reserved <a href="https://beian.miit.gov.cn/#/Integrated/index" rel="nofollow" target="_blank">闽ICP备15016911号-5 </a></p> <p>闽公网安备 <a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=35052402000320" rel="nofollow" target="_blank">35052402000320</a></p> <p> <a href="https://www.wenku365.com/zt.html" target="_blank">专题文集</a> <a href="https://www.wenku365.com/zt-90007.html" target="_blank">丨职业培训</a> <a href="https://www.wenku365.com/zt-90005.html" target="_blank">丨实用范文</a> <a href="https://www.wenku365.com/zt-90010.html" target="_blank">丨商业材料</a> <a href="https://www.wenku365.com/zt-90013.html" target="_blank">丨合同协议</a> <a href="https://www.wenku365.com/zt-90009.html" target="_blank">丨PPT专题</a></p> </div> </footer> <script src="//static.wenku365.com/wenku365/js/global.min.js?"></script> <script src="//static.wenku365.com/wenku365/js/clipboard.min.js?"></script> <script src="//static.wenku365.com/wenku365/js/jquery.treeview.js?"></script> <script src="//static.wenku365.com/wenku365/js/jquery.share.min.js?"></script> <script src="//static.wenku365.com/wenku365/js/common.min.js?"></script> <script src="//static.wenku365.com/wenku365/js/downloadFile.js?"></script> <script src="//static.wenku365.com/wenku365/js/loginWindow.js?"></script> <script src="//static.wenku365.com/wenku365/js/windowRecharge.js?"></script> <script src="//static.wenku365.com/wenku365/js/viewer.min.js?"></script> <script src="//static.wenku365.com/wenku365/js/detail.js?"></script> <!-- 2023-05-07 08:49:06 --> </body> </html>