Spring Roo Petclinic menu.jspx 和控制器。它是如何运作的?
供参考。我确实在 Spring Roo 论坛上发布了此内容,但没有回复。
这是一个新手提出的非常基本的问题。
问题在于控制器如何知道引导菜单链接,例如宠物诊所示例中的以下内容
<menu:item id="i_pet_new" messageCode="global_menu_new" url="/pets?form" z="SwmuMoL7UBbDU/gqHy+t5Tl0Ins="/>
我目前的理解是
@RequestMapping("/pets")
@Controller
public class PetController {
}
处理 url="/pet" 部分,但是
控制器如何知道如何处理剩余部分?上面写着“?form”的部分?
我之前做过简单的mvc项目,我会在PetController类中包含一些代码,它们会执行如下操作:
@RequestMapping("/helloWorld")
public ModelAndView helloWorld() {
ModelAndView mav = new ModelAndView();
mav.setViewName("helloWorld");
mav.addObject("message", "Hello World!");
return mav;
}
在当前示例中,没有其他方法来处理 ModelAndView !
感谢您的帮助。
FYI. I did post this on the Spring Roo forum but no reply.
This is a very basic question from a newbie.
The question is concerning how the Controller knows to direct the menu link , such as the following from the petclinic example
<menu:item id="i_pet_new" messageCode="global_menu_new" url="/pets?form" z="SwmuMoL7UBbDU/gqHy+t5Tl0Ins="/>
My current understanding is that the
@RequestMapping("/pets")
@Controller
public class PetController {
}
Handles the url="/pet" portion but
How does the Controller know how to handle the remaining portion? The portion that says "?form" ?
I have done simple mvc projects before and I would have some code inside of the class PetController that would do something like:
@RequestMapping("/helloWorld")
public ModelAndView helloWorld() {
ModelAndView mav = new ModelAndView();
mav.setViewName("helloWorld");
mav.addObject("message", "Hello World!");
return mav;
}
In the current example there are no additional methods to handle the ModelAndView !
Thanks for the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您会注意到文件
PetController_Roo_Controller.aj
创建在与PetController.java
相同的文件夹中。其中包含处理此问题的相关代码。具体来说,Roo 会为您处理 CRUD 操作。
You will notice the file
PetController_Roo_Controller.aj
created in the same folder asPetController.java
. This contains the relevant code to handle this. Specifically,Roo takes care of the CRUD operations for you.