zoukankan      html  css  js  c++  java
  • JSP内置对象---out get post request

    out对象

    表单提交的方式: 

    <%@ 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>JSP内置对象-request</title>
    </head>
    <body>
        <h1>request内置对象</h1>
        <%
            request.setCharacterEncoding("utf-8");//解决中文乱码问题;  无法解决URL传参传述中文出现乱码的问题
            
            request.setAttribute("password", "123456");//键值对保存
        %>
        用户名:<%=request.getParameter("userName")%><br> 爱好:<%
            if (request.getParameterValues("favorite") != null)
            {
                
                String[] favorite = request.getParameterValues("favorite");
                for (int i = 0; i < favorite.length; i++)
                {
                    out.println(favorite[i] + "&nbsp;&nbsp;");
                }
            }
        %><br>
        密码:<%=request.getAttribute("password") %><br>
        请求体的MIME类型:<%=request.getContentType() %><br>
        协议类型及版本号:<%=request.getProtocol() %><br>
        服务器主机名:<%=request.getServerName() %><br>
        服务器端口名:<%=request.getServerPort() %><br>
        请求文件的长度:<%=request.getContentLength() %><br>
        请求客户端的IP地址:<%=request.getRemoteAddr() %><br>
        请求的真实路径:<%=request.getRealPath("neizhiRequest.jsp") %><br>
        请求的上下文路径:<%=request.getContextPath() %><br>
    
    
    </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>
        <h1>用户注册</h1>
        <hr>
        <form action="neizhiRequest.jsp" name="regForm" method="post">
            <table>
                <tr>
                    <td>用户名:</td>
                    <td><input type="text" name="userName"></td>
                </tr>
                <tr>
                    <td>爱好</td>
                    <td><input type="checkbox" name="favorite" value="read">读书
                        <input type="checkbox" name="favorite" value="music">音乐 <input
                        type="checkbox" name="favorite" value="movie">电影 <input
                        type="checkbox" name="favorite" value="internet">上网</td>
                </tr>
                <tr>
                    <td colspan="2"><input type="submit" value="提交"></td>
                </tr>
            </table>
    
        </form>
        <br>
        <br>
        <a href="neizhiRequest.jsp?userName=李四">测试URL传参数</a>
    </body>
    </html>
  • 相关阅读:
    Hibernate+JPA (EntityMange讲解)
    JPA和Hibernate的区别
    Hibernate与Jpa的关系,终于弄懂
    JEE学习线路
    J2EE中你必须了解的13种技术规范
    js设置datagriad的行移动
    js正则表达式中的特殊字符
    iOS 开发之动画篇
    Phone APP设计规范/iPad APP设计规范/Android APP设计规范/网页设计规范
    打包程序时的证书问题(上传APP就出现Missing iOS Distribution signing indetity for)
  • 原文地址:https://www.cnblogs.com/1ming/p/9429419.html
Copyright © 2011-2022 走看看