码迷,mamicode.com
首页 > 编程语言 > 详细

springMVC---servletAPI

时间:2018-01-01 15:32:22      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:iter   nal   session   locale   www.   world   security   pos   ace   

承接一二章

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();
    }
   }
}

 

springMVC---servletAPI

标签:iter   nal   session   locale   www.   world   security   pos   ace   

原文地址:https://www.cnblogs.com/lnthz/p/8167556.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!