zoukankan      html  css  js  c++  java
  • springMVC---servletAPI

    承接一二章

    index.jsp

    <%@ 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>Hello World</title>
    <a href="springMVC/servletAPI">servletAPI</a>
        <br> <br>
      
      </body>
    </html>
    

     tset.java

    package com.hdxy.domian;
    
    import java.io.IOException;
    import java.io.Writer;
    import java.lang.reflect.Method;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.CookieValue;
    import org.springframework.web.bind.annotation.PathVariable;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.RequestParam;
    
    import com.hdxy.pojo.User;
    
    @RequestMapping("springMVC")
    @Controller
    public class Test {
      /*可以使用serlvet 原生API作为目标方法的参数 具体支持以下类型
       * 
       * HttpServletRequest
       * HttpServletResponse
       * HttpSession
       * java.security.Principal
       * Locale
       * InputStream
       * OutputStream
       * Reader
       * Writer
       * 
       * */
       final public String SUCCESS="loginSuccess";
      
     
     /*  @RequestMapping(value="/servletAPI")
       public String servletAPI(HttpServletRequest requset,HttpServletResponse response){
           System.out.println("servletAPI:"+requset);
           System.out.println("servletAPI:"+response);
           return SUCCESS;
       }*/
     /*  @RequestMapping(value="/servletAPI")
       public void Writer(Writer out){
          try {
            out.write(SUCCESS);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
       
       }*/
       @RequestMapping(value="/servletAPI")
       public void Writer(Writer out){
           try {
            out.write("hello world");
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
       }
    }
  • 相关阅读:
    如何调试在OJ中的代码
    在linux命令行中调试在OJ上的c++代码
    jar包
    stanford core
    decode encode
    访问服务器,远程访问linux主机
    代码18
    删除列表中的元素
    if __name__ == '__main__'
    苹果要求全部新app以及版本号更新必须支持iOS 8 SDK和64-bit
  • 原文地址:https://www.cnblogs.com/lnthz/p/8167556.html
Copyright © 2011-2022 走看看