JavaWeb中servlet中response.setCharacterEncoding,getRealPath方法未定义的解决

来源:互联网 发布:mac 编译php7 编辑:程序博客网 时间:2024/05/17 20:02

今天看了方立勋老师的javaweb视频day06中遇到了下面问题

一,//通过response的writer流输出数据的问题

response.setCharacterEncoding("UTF-8");

出现异常,setCharacterEncoding方法未定义

我的环境:myeclipse2014

解决方法:

在工程的buildpath中

1,删除j2ee支持包

2,导入tomcat 7.x的lib


二,//文件下载

老师写的是:String path = this.getServletContext().getRealPath("/download/1.jpg");

出现异常,方法getRealPath未定义

我的环境:myeclipse2014

改成:

String path = this.getServletConfig().getServletContext().getRealPath("/download/1.jpg");

0 0