使用Spring管理Dispatchaction 可以使用 @Control("name") 来映射,请问MappingDispatchaction会对应好多个path路径那么使用注解的方式该怎么映射呀???

解决方案 »

  1.   

    LZ才发了这一贴。我也不明白LZ的意思
      

  2.   

    我只发了这么一个帖子 - - 哪来的结贴率呀我的意思是这样比如:使用Spring注解来管理Struts我们写了一个action
    <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("???")这个地方该映射成哪个名字,因为名字有很多
      

  3.   

    补充:我想使用MappingDispatchaction的原因是我使用了验证框架,并且对一个ActionForm配置了多种不同的验证策略,如果使用Action,配置会膨胀,使用Dispatchaction不行,因为Dispatchaction中的所有方法使用的是同一个ActionForm对这个ActionForm指定了验证规则会影响到其他方法使用,所以我考虑即能满足一个ActionForm多中验证规则,又能是Action配置不膨胀的最好方式是MappingDispatchaction但是我不会使用Spring的注解映射这种Action,使用<Bean name="/xxx">这种配置文件是没问题的,关键是注解怎么映射 - -
      

  4.   

    @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");
        }
    }
    这是文档的例子看有没有对你有用