mapowanie Spring (@RequestMapping)

0

Witam robie projekt ze springa i mam pytanie odnosnie mapowania.

Mam klase HomeController z takim mapowaniem @RequestMapping("/"). Mam formularz logowania i gdy uzytkownik jest adminem to metoda w kontrolerze UserLoginController robi redirecta do /admin/users. Jak zrobic mapowania by kasowanie uzytkownika zostalo zrealizowane ?

package app.Spring.controllers;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
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 app.Spring.controllers.commands.LogonCommand;
import app.Spring.dao.RegisterService;

@Controller
@RequestMapping("/admin/users")
public class AdminController {

	@Autowired
	RegisterService reg;
	
	@RequestMapping
    public String showUsers(Model model) {
        model.addAttribute("usersList",reg.getAllUsers());
        return "show-users";
    }

    @RequestMapping(value="/{id}")
    public String userDetail(@PathVariable Long id, Model model) {
    	System.out.println("cos");
        model.addAttribute("user", reg.getUser(id));
        return "user-detail";
    }

  

    @RequestMapping(value="/delete.html", method = RequestMethod.GET, params={"did"})
  	public String deleteUser2(Model model, @RequestParam("id") long id,HttpSession session){
      	
      	System.out.println("usuwanie uzytkownika o id "+id);
          reg.deleteUser(reg.getUser(id));
          return "redirect:/show-users";
      }

    @RequestMapping(value="admin/glowna.html", method = RequestMethod.GET)
	protected String handleRequestInternal(ModelMap model) throws Exception {
		
		
		return "redirect:/";
	}
	
	
	
	
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<head>
 <link href="<c:url value="/resources/myTh/css/moje.css" />"
	rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body> 
<H1>Lista Produktów</H1>
<H3>Implementacja widoku z tagów JSTL(JSP Standard Tags Library)</H3>
<div id="productList">

<c:if test="${empty usersList}">
	Lista uzytkownikow jest pusta
</c:if>

<c:if test="${not empty usersList}">
	Lista zawiera ${fn:length(usersList)} uzytkownikow
	
	<c:set var="boundMin" value="${25}"/>
	<c:set var="boundMax" value="${40}"/>
	
	<table border="1">
		<tr>
		    <th>Detale</th>
			<th>Nazwa</th>
			<th>haslo</th>
			<th>id</th>
		</tr>
		<c:forEach items="${usersList}" var="user">
			<tr>
				<td>
					<a href="delete.html?did=${user.id}" class="shiny-button" > ${user.username}</a>
				</td>
				
   			
				<td>${user.username}</td>
				<td>${user.password}</td>
				<td>${user.id}</td>
				<td>
					<a href="?id=${user.id}" class="shiny-button" >Edytuj</a>
					<a href="productForm.html?id=${product.id} "class="shiny-button" >Edytuj</a>
					
				</td>
				
				
			</tr>
			
		</c:forEach>
		
	</table>
	
</c:if>

</div>
</body>
</br>
<a href="productForm.html" class="shiny-button"  >Dodaj Nowy</a> <a href="cart.html"  class="shiny-button"  >koszyk</a> <a href="glowna.html"  class="shiny-button" >Powrot do glownej</a>

1 użytkowników online, w tym zalogowanych: 0, gości: 1