testcontroller.java 1.19 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
package com.example.demo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class testcontroller {
		@RequestMapping("/file")
		
		public String viewTest(@PathVariable String name,HttpServletRequest req) {
			HttpSession session = req.getSession();
			
			session.setAttribute(name, name);
					
			return "file.jsp";
		}
		
		
		@GetMapping("/empleado/{id}")
		public ModelAndView	veremp (@PathVariable String id) {
		empleado emp = new empleado (1,"Joaquin","Jefe");
		
		System.out.println("LLegue");
		
		ModelAndView mv = new ModelAndView();
		mv.setViewName("emp");
		mv.addObject("emp",emp);
		return mv;

	}	

		/*
	public ModelAndView courses() {	
		@PostMapping("/addcourse")
		return ModelAndView ("courses","course",new course());
		
	}
		
		
		@RequestMapping(value="/courses");
		
		
		
		
		*/
		
	
}