zoukankan      html  css  js  c++  java
  • JSP中的细节

    1.注释

      <!---->与<%---->的区别

    2.ContentType与pageEncoding中的charset的区别

      pageEncoding指的是服务器加载jsp时编码,文件编码与其不一致,JSP翻译成的Servlet中会有中文乱码。

      ContentType是指定服务器和浏览器用什么显示的编码,如果JSP翻译成的Servlet中有中文乱码,无论ContentType的charset设置成什么永远是乱码,因为浏览器

    输出的JSP翻译过后的字符,这个字符本身就是乱码的;同理,如果JSP翻译成的Servlet中没有中文乱码,无论ContentType的charset设置成什么永远都不会乱码。

       即ContentType与pageEncoding中的chartset是没有关联的。

       

      另外,关于乱码。要注意字符原本就是乱码字符的情况。

    3.jsp中的include指令

      问题1:一个jsp中嵌入另外一个jsp页面

          

    An error occurred at line: 3 in the jsp file: /include/2.jsp
    Duplicate local variable path
    1: <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    2: <%
    3: String path = request.getContextPath();
    4: String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    5: %>

      这得从JSP的翻译说起,jsp2中也有一个<% path = ... basePath = ...%>,翻译就是重复定义了变量,自然而然就会出错了。把jsp2的这段代码删除掉就没有问题了。

        

  • 相关阅读:
    6.Mysql之MGR的限制和局限性
    5.Mysql之MGR原理浅谈02
    2.shell之cut详解
    1.Shell编程的基本语法01
    4.Mysql之MGR浅谈01
    3.Mysql之MHA实战(03)
    2.Mysql之高可用架构MHA(02)
    1.数据库的三大范式是什么?
    1.Mysql之主从复制浅谈01
    6.Mydumper和Myloader备份恢复
  • 原文地址:https://www.cnblogs.com/XinYiWorldBlog/p/5242837.html
Copyright © 2011-2022 走看看