package com.lynas.controller;
@Controller
@RequestMapping("/product")
public class ProductController {
@Autowired
private EUserService userDao; //for Service
//This is a normal method not a controller methodprivate String getCurrentUser(){
return "MyString";
}
//controller method for dealing with form post method@RequestMapping(value="/registeruser", method = RequestMethod.POST)
public ModelAndView registerUser(HttpServletRequest request,@RequestParam String username,@RequestParam String password,@RequestParam String email){
return new ModelAndView(forwardPage); // this is for forwarding to a new model view
}//controller method that just show the view
@RequestMapping(value="/home")
public ModelAndView home(){
return "home"; //home is the jsp page for view
}@RequestMapping(value = "/addnewproduct", method = RequestMethod.POST)
@PreAuthorize("hasAnyRole('ROLE_USER')") // this is for defining which type of user can access this method
public String addNewProduct() {
return "myproduct";
}
@RequestMapping(value = "/getsubcategory")@ResponseBody // this is a controller method for dealing with ajax call
public String approveOneUser(@RequestParam String category) {
return stringBuilder.toString();
}
@RequestMapping(value = "/addToWishlist/{itemId}") // this is for grabbing path variable
@PreAuthorize("hasAnyRole('ROLE_USER','ROLE_ADMIN')")
public String wishListAdd(@PathVariable int itemId) {
return "updated";
}
}