• 留言板(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>

    运行结果:

  • 相关阅读:
    Python join方法
    Python字符串capitalize center 方法
    Python int 中 add abs 方法
    Nginx Windows 安装启动
    Angularjs 首次加载显示{{}}
    Mysql 字符串截取
    Mysql 主键常用修改
    AES 加密256位 错误 java.security.InvalidKeyException: Illegal key size or default parameters
    Tocmat 启动错误 Port 8005 required by tomcat v7.0 server at localhost is already in use
    Socket IO Web实时推送
  • 原文地址:https://www.cnblogs.com/miss123/p/5631811.html
Copyright © 2020-2023  润新知