9月19日 微服务架构 周三

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>



  
    
    
    My JSP 'list.jsp' starting page
    
	
	
	    
	
	
	

  
  
  
  	
  			
id name sex age 操作 |
${s.ID} ${s.STUNAME} ${s.STUSEX} ${s.STUAGE}



	
	

package com.hao.controller;

import java.util.List;
import java.util.Map;

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

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hao.dto.User;
import com.hao.service.IUserService;

@Controller
@RequestMapping("user")
public class UserController {

	@Autowired
	private IUserService iUserService;
	@RequestMapping("login")
	public String login(User user,HttpServletRequest request){
		HttpSession session = request.getSession();
		System.out.println(user);
		User u = iUserService.login(user);
		System.out.println(u);
		if(u!=null){
			System.out.println("登录成功");
			session.setAttribute("u", u);
			session.setAttribute("uid", u.getId());
			return "main";
		}else{
			System.out.println("登录失败");
			return "loginfail";
		}
	}
	@RequestMapping("getTree")
	@ResponseBody
	public List getTree(Integer id){
		List tList = iUserService.getTree(id);
		System.out.println(tList);
		return tList;
	}
	@RequestMapping("toLog")
	public String toLog(HttpServletRequest request){
		HttpSession session = request.getSession();
		session.invalidate();
		return "loguser";
	}
	
	@RequestMapping("top")
	public String top(){
		return "top";
	}
	@RequestMapping("left")
	public String left(){
		return "left";
	}
	@RequestMapping("right")
	public String right(){
		return "right";
	}
	@RequestMapping("chars")
	public String chars(){
		return "chars";
	}
}

package com.hao.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.hao.service.ITableService;

@Controller
@RequestMapping("table")
public class TableController {

	@Autowired
	private ITableService iTableService;
	@RequestMapping("list")
	public String list(HttpServletRequest request,Integer id){
		System.out.println(id);
		List> sList = iTableService.findStuList();
		request.setAttribute("id", id);
		request.setAttribute("sList", sList);
		return "list";
	}
	@RequestMapping("toAdd")
	public String toAdd(){
		return "add";
	}
}

“天下的事 并不是你所求 就能所得”
《如懿传》

你可能感兴趣的:(2018)