老师你看下我这个,我也登不上去
webdemo.zip
public class TestPNG extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("img/png"); File file=new File("E:/img.png"); FileInputStream fileInputStream=new FileInputStream(file); byte[] bytes=new byte[fileInputStream.available()];//注意是小写的byte fileInputStream.read(bytes); OutputStream outputStream=resp.getOutputStream(); outputStream.write(bytes); outputStream.flush(); outputStream.close(); } }
老师,为什么我这块代码在浏览器显示不了图片反而是直接下载了
// req.setCharacterEncoding("utf-8"); String username=req.getParameter("username");//获取单个value //解决控制台乱码 // String name=new String(username.getBytes("iso-8859-1"),"utf-8"); System.out.println(username); // System.out.println(name);
老师,我的直接注释掉重新编码可以显示中文,但是按照老师的办法是不行的,控制台会显示乱码,是整个编码过程哪里出问题了吗
老师,我的windows10下的用户名是中文的,会有影响吗?
老师,这个数据库 是需要 提前自己 去编写的吗?
还是 在系统启动 tomcat 数据库会自动链接生成?
使用中文时,设置响应编码 ,和下面设置响应类型不冲突吗?但是 可以正常运行和显示出来
老师,你看下我的代码,我照着写的,还是 报错了。
package com.liyang.dao; import com.liyang.commons.JdbcUtils; import com.liyang.pojo.Users; import java.sql.Connection; import java.sql.PreparedStatement; public class UserLoginDaoImpl implements UserLoginDao { //用户登录的数据查询 @Override public Users selectUsersByUserNameAndUserPwd(String username, String userpwd) { Connection conn=null; try{ conn= JdbcUtils.getConnection(); preparedStatement ps=conn.prepareStatement("select *from users where username = ? and userpwd = ?"); }catch (Exception e){ e.printStackTrace(); }finally { } return null; } }
老师这一步是 干嘛的呢。
作用做什么的呢、
获取连接 是获取什么的链接
jdbc.driver=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://localhost:3306/cxx?useUnicode=true&characterEncoding=utf-8&useSSL=false jdbc.username=root jdbc.password=root
IDEA 设置里面的语言也改成了 utf-8 往数据库里插入还是乱码
老师为什么我这<br/>换行怎么没实现还打印出来了
老师,我在更新用户的时候,提交之后就给我报500异常,是哪里有问题呀
webdemo.rar
为什么删除时,后面都要跟一个空字符串?有什么作用呢?
老师请问这是什么问题啊一直到不了网页就报错代码跟老师的都一样啊
老师,有没有jsp的API文档?~~~~~~~~~~~
老师,为什么我的还是乱码,在IDEA控制台输出中文文件名也是乱码
DownloadServlet HttpServlet { (HttpServletRequest reqHttpServletResponse resp) ServletExceptionIOException { .doPost(reqresp)} (HttpServletRequest reqHttpServletResponse resp) ServletExceptionIOException { File file=File()System..println(file.getName())FileInputStream fis=FileInputStream(file)[] b=[fis.available()]fis.read(b)resp.addHeader(+String(file.getName().getBytes()))OutputStream os=resp.getOutputStream()os.write(b)os.flush()os.close()} }
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637