I am working on a project using hibernate and Spring MVC architecture. My problem is that I am using (*.htm) url pattern in my web application , in this case when I sent a product's id to controller for editing, the product's id is shown in url for eg.
"localhost:8080/MyApp/editProduct.htm?productId=03".
But I don't want this . I just want
"localhost:8080/MyApp/editProduct.htm?productId" or "localhost:8080/MyApp/editProduct.htm/productId/03"
and I am unable to use @PathVariable Annotation in my controller because of my url pattern(*.htm) and using of @PathVariable Annotation the JSP page never load properly. Any Suggestions . Thanks in Advance.
Controller:-
@RequestMapping(value = "/{sId}/deleteState.htm")
public ModelAndView deleteState(@PathVariable("sId") int sId ){
ModelAndView mav = new ModelAndView();
try{
stateDAO.deleteById(sId);
mav.addAllObjects(prepapareModel());
mav.addObject("msg", "State Deleted Succesdfully");
mav.setViewName("admin/viewState");
return mav;
}catch(Exception e){
e.printStackTrace();
mav.addAllObjects(prepapareModel());
mav.addObject("err", "Failed to Delete State");
mav.setViewName("admin/viewState");
return mav;
}
}
public Map prepapareModel(){
Map map = new HashMap();
map.put("states", stateDAO.findAll());
return map;
}
Url after deleting the State from database:-
http://localhost:8080/PujaInBox/10/deleteState.htm
I think the Id of State is creating the problem . 10 is Id of state.