使用Spring管理Dispatchaction 可以使用 @Control("name") 来映射,请问MappingDispatchaction会对应好多个path路径那么使用注解的方式该怎么映射呀???
解决方案 »
- js 向session取值的问题!!!神奇的错误!!
- 如何将FCKeditor设置为只读
- java se基础问题,请教高手解释一下
- html网页上放一个表单,上面放了很多checkbox,在提交这个表单时候,执行一个javascript函数,如何在这个函数里知道我哪些checkbox被选择了?
- jsp 鼠标事件
- jsp中bean的scope属性取值分别为page 和request的区别是什么啊?
- 求一算法
- 关于设置session为ivalidate()或者removeAttribute("XX")的问题!
- Jsp分页问题。。。
- servlet中调用bean的问题。
- 做java的在苏州有没有发展前景
- spring+hibernate+proxool的配置问题
<action path="/user" path="com.xxx.xxx.User"></action>那么在Action当中我们重写execute@Controller("/user")//这里要映射成
public class UserRegister extends Action { public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// TODO Auto-generated method stub
return super.execute(mapping, form, request, response);
}
}
那么问题是MappingDispatchaction,这种Action是好多个path指向一个类例如
<action path="/user1" path="com.xxx.xxx.User"></action>
<action path="/user2" path="com.xxx.xxx.User"></action>
<action path="/user3" path="com.xxx.xxx.User"></action>那么@Controller("???")这个地方该映射成哪个名字,因为名字有很多
@RequestMapping("EDIT")
@SessionAttributes("site")
public class PetSitesEditController { private Properties petSites; public void setPetSites(Properties petSites) {
this.petSites = petSites;
} @ModelAttribute("petSites")
public Properties getPetSites() {
return this.petSites;
} @RequestMapping // default (action=list)
public String showPetSites() {
return "petSitesEdit";
} @RequestMapping(params = "action=add") // render phase
public String showSiteForm(Model model) {
// Used for the initial form as well as for redisplaying with errors.
if (!model.containsAttribute("site")) {
model.addAttribute("site", new PetSite());
}
return "petSitesAdd";
} @RequestMapping(params = "action=add") // action phase
public void populateSite(
@ModelAttribute("site") PetSite petSite, BindingResult result,
SessionStatus status, ActionResponse response) { new PetSiteValidator().validate(petSite, result);
if (!result.hasErrors()) {
this.petSites.put(petSite.getName(), petSite.getUrl());
status.setComplete();
response.setRenderParameter("action", "list");
}
} @RequestMapping(params = "action=delete")
public void removeSite(@RequestParam("site") String site, ActionResponse response) {
this.petSites.remove(site);
response.setRenderParameter("action", "list");
}
}
这是文档的例子看有没有对你有用