当前位置: 代码迷 >> Java Web开发 >> 为什么这样编写的jsp文件还是出现乱码,该怎么处理
  详细解决方案

为什么这样编写的jsp文件还是出现乱码,该怎么处理

热度:23   发布时间:2016-04-17 14:13:09.0
为什么这样编写的jsp文件还是出现乱码

代码
<%@   page   language= "java "   contentType= "text/html;   charset=GBK "%>    
<%      
        //request.setCharacterEncoding( "GBK ");      
        String   contentId   =   request.getParameter( "contentId ");      
%>    
<html>    
<head>    
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=GBK ">    
<title> Jsp   Test </title>    
</head>    
<body>    
<form   method   =   "post "   action= "ActionVerify.jsp ">    
<table>    
        <tr>    
                <td>    
                        <input   name   =   "contentId "   type   =   "text "   value=   " <%=contentId   %> ">    
                </td>    
                <td>    
                        <input   name   =   "submit "   type   =   "submit "   value=   "提交 ">    
                </td>    
        </tr>    
</table>    
</form>    
</body>    
</html>    
   
<%@   page   language= "java "   contentType= "text/html;   charset=GBK "%>    
<%      
//request.setCharacterEncoding( "GBK ");      
%>    
<html>    
<head>    
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=GBK ">    
<title> Insert   title   here </title>    
</head>    
<body>    
<form   action= " ">    
        <table>    
                <tr>    
                        <td>    
                                <%=request.getParameter( "contentId ")   %>    
                        </td>    
                </tr>    
        </table>    
</form>    
   
</body>    
</html>    


我已经设置了编码方式为GBK,但是我设置了request.setCharacterEncoding( "GBK ");就可以正常显示, <%@   page   language= "java "   contentType= "text/html;   charset=GBK "%> 不能起到当前页面全局作用的效果吗?  
  相关解决方案