this is my index page:
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <h1>Employee List</h1> <table border="2" width="70%" cellpadding="2"> <tr><th>Name</th><th>Address</th> <th>City</th><th>Cars</th></tr> <c:forEach var="emp" items="${list}"> <tr> <td>${emp.name }</td> <td>${emp.address }</td> <td>${emp.city }</td> <td>${emp.cars}</td> <td><a href="editemp/${emp.name }">Edit</a> <td><a href="deleteemp/${emp.name }">Delete</a> </tr></c:forEach> </table> <a href="empform">Add New Employee</a>"
problem is when i click on other link than it works fine but when i click on editemp or deleteemp link,than it shows me error:The requested resource is not available
This is my controller class:
package first; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ModelAttribute; 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.servlet.ModelAndView; @Controller public class EmpController { @Autowired EmployeeDao dao; @RequestMapping("/empform") public ModelAndView showForm() { return new ModelAndView("empform","command",new Employee()); } @RequestMapping(value="/save",method=RequestMethod.POST) public ModelAndView save(@ModelAttribute("emp") Employee employee) { dao.saveEmployee(employee); return new ModelAndView("redirect:/viewemp"); } @RequestMapping("/viewemp") public ModelAndView viewemp() { List<Employee> list=dao.getAllEmployee(); return new ModelAndView("viewemp","list",list); } @RequestMapping(value="/editemp/{name}",method=RequestMethod.GET) public ModelAndView edit(@PathVariable String name) { Employee e=dao.getbyName(name); return new ModelAndView("empeditform","command",e); } @RequestMapping(value="/saveedit",method=RequestMethod.POST) public ModelAndView saveedit(@ModelAttribute("emp")Employee employee) { dao.updateEmployee(employee); return new ModelAndView("redirect:/viewemp"); } @RequestMapping(value="/deleteemp/{name}",method=RequestMethod.GET) public ModelAndView delete(@PathVariable String name) { dao.delete(name); return new ModelAndView("redirect:/viewemp"); } }
Please tell me,why it is unable to map with controller method specified in controller class.....thanks in advance