• JSP实现成语接龙


    首页: 

    <%--
      Created by IntelliJ IDEA.
      User: zdd
      Date: 2019/11/18
      Time: 10:15
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
    <head>
        <title>成语接龙首页</title>
    </head>
    <body>
    四字成语接龙<br>
    你输入的成语为:
    <%
        String s = (String)application.getAttribute("message");
        if(s!=null){
            out.println(s);
        }else{
            out.println("还没有成语,请输入:<br>");
        }
    %>
    <form action="jielong.jsp" method="post">
        <br>
        输入成语:<input type="text" name="mess"/><br>
        <input type="submit" value="提交"/>
    </form>
    </body>
    </html>
    

    处理页面 

    <%--
      Created by IntelliJ IDEA.
      User: zdd
      Date: 2019/11/18
      Time: 10:21
      To change this template use File | Settings | File Templates.
    --%>
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
    <head>
        <title>jielong.jsp</title>
    </head>
    <body>
    <%!
        String message = "";
        ServletContext application;
        synchronized void sendmessage(String s){
            application= getServletContext();
            message = message+s+"--->";
            application.setAttribute("message",message);
        }
    %>
    <%
        request.setCharacterEncoding("UTF-8");
        String content = request.getParameter("mess");
        sendmessage(content);
        out.println("你的成语"+content+"已经提交");
        response.setHeader("refresh","3;chengyu.jsp");
    %>
    
    </body>
    </html>
    

    运行结果:

                                    

              

     
  • 相关阅读:
    5.MFC基础(五)视图、运行时类信息、动态创建
    4.MFC基础(四)菜单、工具栏、状态栏
    OpenCV Python 4.0安装
    windows批量导出文件名到txt
    *&p理解
    VS调试快捷键配置更改
    数组类的创建(下)
    数组类的创建(上)
    operator用法:隐式类型转换
    C++单例模式
  • 原文地址:https://www.cnblogs.com/zhahu/p/11931373.html
Copyright © 2020-2023  润新知