编写留言簿的一个问题, 研究了三天了也没看出来哪里不对, 请各位大神给支个招
2015-11-27 17:02
519 查看
程序代码:
程序代码:
程序代码:
我输入"世界", 然后留言内容是"中午饭不回家吃了"
这个运行的时候不能输入中文, 研究了好久好像是转码的问题, 改了好多遍还是这样, 捕捉回来的信息是 java.lang.IllegalArgumentException: Cookie name "世界" is a reserved token
各位大神帮帮忙指一下错误吧
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>编辑页面</title> </head> <body> <form action="6.9.2(2).jsp" method="post"> <table> <tr> <td>留言给<input size="10" type="text" value="" name="nm1" /></td> </tr> <tr> <td><textarea rows="10" cols="50" name="nm2"></textarea></td> </tr> <tr> <td><input type="submit" value="提交" /></td> </tr> </table> </form> <form action="6.9.2(3).jsp"><input type="submit" value="显示留言"/></form> </body> </html>
程序代码:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="java.net.URLDecoder" %> <%@page import="java.net.URLEncoder" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <% request.setCharacterEncoding("UTF-8"); try { String a = request.getParameter("nm1"); String b = request.getParameter("nm2"); if(a==""||a==null||a.length()==0) { out.print("请将姓名填写完整"); } else if(a!="") { Cookie c = new Cookie(a,b); c.setMaxAge(60*60*3); response.addCookie(c); out.print("留言已添加..."); response.setHeader("refresh","3;URL=6.9.2(1).jsp"); } } catch (Exception e) { out.println(e); } %> <form action="6.9.2(1).jsp"><input type="submit" value="写留言" /></form> <form action="6.9.2(3).jsp"><input type="submit" value="显示留言"/></form> </body> </html>
程序代码:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="java.net.URLDecoder" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <% request.setCharacterEncoding("UTF-8"); Cookie[] co = request.getCookies(); if(co != null) { for(int i = 0; i<co.length; i++) { out.print("To "+co[i].getName()+"——"+co[i].getValue()); out.print("</br>"); } } %> <form action="6.9.2(1).jsp"><input type="submit" value="写留言" /></form> </body> </html>
我输入"世界", 然后留言内容是"中午饭不回家吃了"
这个运行的时候不能输入中文, 研究了好久好像是转码的问题, 改了好多遍还是这样, 捕捉回来的信息是 java.lang.IllegalArgumentException: Cookie name "世界" is a reserved token
各位大神帮帮忙指一下错误吧
相关文章推荐
- jQuery.each(object, [callback])方法,用于处理json数组
- 最近有点迷茫,所以开始随想系列
- sar监控工具详解
- Linux常用命令
- 静态代码检测工具Cpplint
- 23设计模式之代理模式(Proxy)
- 如何解除Win10默认网速限制 Windows10解除网速限制的设置教程
- C++别名传参和指针传参区别
- 远程连接mysql被拒绝问题
- 爬虫之自动保存文档-使用python/selenium
- activiti如何在任务办理时查看任务表单
- 工业4.0,给我们的未来敲响了一个警钟
- 数据库索引的实现原理
- 23设计模式之抽象工厂(Abstract Factory)
- maven
- 为嵌套在左右滑动的UIScrollview上的UITableView增加滑动删除
- J2EE开发技术点6:Proxool数据库连接池
- 利用BIOS INT 0x13读取软盘
- JavaScript 获取dom外联样式
- 23设计模式之策略模式(Strategy)