Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ajax 如何在spring mvc中加载主页数据_Ajax_Spring_Jsp_Model View Controller_Controller - Fatal编程技术网

Ajax 如何在spring mvc中加载主页数据

Ajax 如何在spring mvc中加载主页数据,ajax,spring,jsp,model-view-controller,controller,Ajax,Spring,Jsp,Model View Controller,Controller,我有一个主页,其中包含城市、国家、州、用户详细信息以及一些饼图和代表用户数据分析的图表。我是spring mvc的新手,我不知道是应该一次性加载主页数据,还是应该进行onclick调用,调用我的控制器并加载数据 Example: MyController Class public class HomeController { @Autowired private EngagaementService engagaementService;

我有一个主页,其中包含城市、国家、州、用户详细信息以及一些饼图和代表用户数据分析的图表。我是spring mvc的新手,我不知道是应该一次性加载主页数据,还是应该进行onclick调用,调用我的控制器并加载数据

    Example:
    MyController Class
    public class HomeController {

        @Autowired
        private EngagaementService engagaementService;

        @Autowired
        private EmployeeService employeeService;

        @Autowired
        private CgOfficeDetailsService cgOfficeDetailsService;



        @RequestMapping("/")
        public ModelAndView handleRequest() {
            List<EmployeeInfo> listEmployees = employeeService.listEmployeeInfos();
            ModelAndView model = new ModelAndView("index");
            model.addObject("emp", listEmployees);
            model.addObject("empCount", listEmployees.size());
            return model;
        }

        @GetMapping("/getCity")
        public ModelAndView getBU(HttpServletRequest request) {
            String country = "India";
            List<String> buList = employeeService.getCityName(country);
            ModelAndView model = new ModelAndView("index");
            model.addObject("buList", buList);
            return model;
        }

        @GetMapping("/getState")
        public ModelAndView getState(HttpServletRequest request) {
            String country = "UP";
            List<String> buList = employeeService.getState(country);
            ModelAndView model = new ModelAndView("index");
            model.addObject("buList", buList);
            return model;
        }

        @GetMapping("/getUsers")
        public ModelAndView getUsers(HttpServletRequest request) {
            String country = "UP";
            List<String> buList = employeeService.getState(country);
            ModelAndView model = new ModelAndView("index");
            model.addObject("buList", buList);
            return model;
        }
示例:
MyController类
公共类家庭控制器{
@自动连线
私人工程服务工程服务;
@自动连线
私人雇员服务;
@自动连线
私人cgofficedetails服务cgofficedetails服务;
@请求映射(“/”)
公共模型和视图句柄请求(){
List listEmployees=employeeService.listEmployeeInfos();
ModelAndView模型=新的ModelAndView(“索引”);
addObject(“emp”,listEmployees);
addObject(“empCount”,listEmployees.size());
收益模型;
}
@GetMapping(“/getCity”)
公共模型和视图getBU(HttpServletRequest){
字符串country=“印度”;
List buList=employeeService.getCityName(国家);
ModelAndView模型=新的ModelAndView(“索引”);
model.addObject(“buList”,buList);
收益模型;
}
@GetMapping(“/getState”)
公共模型和视图获取状态(HttpServletRequest){
字符串country=“UP”;
List buList=employeeService.getState(国家);
ModelAndView模型=新的ModelAndView(“索引”);
model.addObject(“buList”,buList);
收益模型;
}
@GetMapping(“/getUsers”)
公共模型和视图getUsers(HttpServletRequest){
字符串country=“UP”;
List buList=employeeService.getState(国家);
ModelAndView模型=新的ModelAndView(“索引”);
model.addObject(“buList”,buList);
收益模型;
}

这是一个权限问题。我想设计我的应用程序体系结构,以便可以按需使用当前/特定授权级别(可以说)访问的所有数据

如果是这样,(我假设这是您的情况,因为我在您的代码中没有看到任何进一步的身份验证),这只是视图设计(前端设计)的问题