java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

版权声明:博客知识产权来源命运的信徒,切勿侵权 https://blog.csdn.net/qq_37591637/article/details/86642737

错误代码如下



报错之处

我只是在jsp页面上写了两行java代码,就报错;

<%String a=(String ) request.getAttribute("current"); %>
            <%=a %>

尝试

删除这两行代码就不报错了;


原因

current在servelet封装之前本来就是int类型

 


 改变如下

<%Integer a=(Integer) request.getAttribute("current"); %>
            <%=a %>

 就不报错了

猜你喜欢

转载自blog.csdn.net/qq_37591637/article/details/86642737