servlet中的数据传递
servlet中的数据传递
使用request的setAttribute()方法
传递方:
request.setAttribute("str","用户名或者密码错误");
接收方:
String str = (String) request.getAttribute("str")
注:因为request.getAttribute()返回的是object对象,所以这里使用了类型转换接收
若要让servlet返回的数据中文显示不乱码需要设置
request.setCharacterEncoding("utf-8");
response.setCharacterEncoding("gbk");
本人是个刚入职的小菜鸡,写下来只是一些随笔,用来自己回顾,很多东西不一定正确,只是我当下自己的理解,请各位大神,有错误的地方可以指出来哈。

浙公网安备 33010602011771号