点击控制器弹簧的树节点调用动作

时间:2014-07-21 05:37:29

标签: jquery ajax spring

我是春季开发的新手。点击树节点我想为不同的节点显示不同的页面。 对于树,我正在使用jqtree插件。

在父节点上单击我想渲染companyPage并在子节点上单击想要显示devicePage

$('#tree1').bind(
      'tree.select',
      function(event) {
        if (event.node) {
        // node was selected
        var node = event.node;
        selectedNode = node;
        //If node is parent ie company node

        if(node.id == 1){
           $.ajax({  
                type : "Get",   
                url : "company.html"});
           });
        }

        //Device NOde
        else{
           $.ajax({  
                type : "Get",   
                url : "device.html"});
           });
        }
      }
    }
    );
}); 

控制器是

@RequestMapping(value = "/company", method = RequestMethod.GET)
  public String company(Locale locale, Model model) {
      logger.info("Here in company action.", locale);
      return "companyPage";
}

 @RequestMapping(value = "/device", method = RequestMethod.GET)
    public String device(Locale locale, Model model) {
      logger.info("Here in device action.", locale);
      return "devicePage";
}

我在控制台上点击父节点时收到“此处在公司行动中”,但未呈现companyPage。

为什么?

我认为我错误地使用ajax

任何解决办法吗?

Spring config

<!-- DispatcherServlet Context: defines this servlet's request-processing   infrastructure -->
   <context:component-scan base-package="........" />
   <!-- Enables the Spring MVC @Controller programming model -->
   <mvc:annotation-driven />

   <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<mvc:resources mapping="/resources/**" location="/resources/" />

<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/WEB-INF/views/" />
    <beans:property name="suffix" value=".jsp" />
</beans:bean>

和其他bean如messageSource,dataSource,SessionFactory和.......

0 个答案:

没有答案