私は、Spring MVC アプリケーションで構成パラダイムを介して grails の規則を模倣しようとしてきましたが、ハンドラー マッピングを自動化するのが難しいと感じています。
基本的に私はこのようなコントローラーを持っています。
@Controller
@RequestMapping(value = {"/", "/contact"})
public class ContactController {
@Autowired
private ContactService contactService;
@RequestMapping(value = {"/","/index"})
public String listContacts(Map<String, Object> map){
map.put("contact", new Contact());
map.put("contactList", contactService.listContact());
return "contact";
}
@RequestMapping(value = "/add", method = RequestMethod.POST)
public String addContact(@ModelAttribute("contact")Contact contact, BindingResult result){
contactService.addContact(contact);
return "redirect:/contact/index";
}
@RequestMapping(value = "/delete/{contactId}", method = RequestMethod.GET)
public String removeContact(@PathVariable("contactId")Long contactId){
contactService.removeContact(contactId);
return "redirect:/contact/index";
}
}
今、「ControllerClassNameHandlerMapping」を試してみましたが、3つの部分のURLに制限があるようです。
基本的に、 @RequestMapping を使用せずに、すべてのリクエストを適切なコントローラーとアクションに自動的にマップしたい
どんなポインタでも大きな助けになります