留言板(application)
Posted 鱼在我这里
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了留言板(application)相关的知识,希望对你有一定的参考价值。
用application制作简单留言板
<%@ 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="55555.jsp" method="post"> <table> <tr> <td>昵称:</td> <td><input type="text" name="name"/></td> </tr> <tr> <td>邮箱:</td> <td><input type="text" name="email"/></td> </tr> <tr> <td>留言内容:</td> </tr> </table> <table> <tr> <td><textarea name="liuyan" rows="20" cols="60"></textarea></td> </tr> </table> <table> <tr> <td><input type="submit" value="提交"/></td> <td><input type="reset"/></td> </tr> </table> </form> </body> </html>
处理界面:
<%@ 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>Insert title here</title> </head> <body> <% String name=new String(request.getParameter("name").getBytes("ISO-8859-1"),"UTF-8"); String email=request.getParameter("email"); String liuyan=new String(request.getParameter("liuyan").getBytes("ISO-8859-1"),"UTF-8"); if(name==""||email==""||liuyan=="") { out.print("请把内容补充完整,5秒后跳转到留言界面"); response.setHeader("refresh", "5;appliuyan.jsp"); } else { String s="姓名:"+name+"<br>邮箱:"+email+"<br>留言内容:"+liuyan+"<br>"; String message1=(String)application.getAttribute("message"); if(message1==null) { application.setAttribute("message", s); } else { message1+=s; application.setAttribute("message", message1); } out.print("留言提交成功!"); } %> <form action="66666.jsp"> <table> <tr><td>查看其它留言</td></tr> <tr><td><input type="submit" value="查看"/></td></tr> </table> </form> </body> </html>
<%@ 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>Insert title here</title> </head> <body> <% String str=(String)application.getAttribute("message"); out.print(str); %> <a href="appliuyan.jsp">继续留言</a> </body> </html>
运行结果:
以上是关于留言板(application)的主要内容,如果未能解决你的问题,请参考以下文章
SpringBoot中表单提交报错“Content type ‘application/x-www-form-urlencoded;charset=UTF-8‘ not supported“(代码片段
add application window with unknown token XXX Unable to add window;is your activity is running?(代码片段
add application window with unknown token XXX Unable to add window;is your activity is running?(代码片段