日期:2014-05-18  浏览次数:20641 次

JSP页面指令冲突问题
<%@   page   contentType= "text/html;   charset=GBK "   %>
<%@   include   file= "admintop.jsp "%>

<%   request.setCharacterEncoding( "GB2312 ");%>
<%if(session.getValue( "username ")==null){
    out.print( " <script> alert( '对不起,请先登录 ');document.location.href= 'adminindex.jsp ' </script> ");
}%>
<html>
<head>
<title> 管理首页 </title>
</head>
<body>
<table   width= "100% "   border= "1 "   align= "center "   bordercolor= "#000000 ">
    <tr>
          <td   heigth= "30 "   bgcolor= "#B6D7E7 ">
              <div   align= "center "> <strong> 登录成功 </strong> </div> </td>
          </td>
    </tr>
    <tr>
          <td   background= " "> 你可以在此对后台进行操作,可以对左侧选择对象管理,也可以对管理员帐户进行管理。 </td>
    </tr>
    <tr>
          <td   background= " ">
            <div   align= "center "> 如果在使用中遇到问题请及时和我联系! </div>
          </td>
    </tr>
</body>
</table>
</html>

==================================
报错: "adminbody.jsp ":   /government/manager/admintop.jsp(0,0)   Page   directive:   can 't   have   multiple   occurrences   of   contentType   at   line   3,   column   1

==================================
只要去掉 <%@   page   contentType= "text/html;   charset=GBK "   %>
<%@   include   file= "admintop.jsp "%> 这两个中的一个,就不会报错了,但是去掉第一行页面上的字就会是乱码,而文件肯定也是要包含的(包含文件的本身肯定没有问题)。
我想问:1,为什么会出现这种情况,能不能解决。
                2,或者用其他变通的方法能实现我上面的两个要求也行,但我不需要         javabean


------解决方案--------------------
在你的admintop.jsp也设置了 <%@ page contentType= "text/html; charset=GBK " %> ?如果有把这句去掉就可以了。

------解决方案--------------------
<%@ page contentType= "text/html; charset=GBK " %>
指令冲突,把这个页面或admintop.jsp的 <%@ page contentType= "text/html; charset=GBK " %>
删掉就可以了,这个是有点乱,根tomcat的版本有关系!
------解决方案--------------------
让主页面和admintop.jsp页面里的 <%@ page contentType= "text/html; charset=GBK " %> 一模一样就可以了。我也是这样的问题,不知道是tomcat原因还是java的原因,是tomcat的话马上换。。。。烦死了