HTTP参数的网址失败

时间:2017-03-05 22:22:03

标签: java spring heroku

在我的应用程序中,我正在尝试访问网址https://findraft.herokuapp.com/customer/programDetails?programInfoId=2,我收到404错误。 以下是日志消息

但是在我的本地dev tomcat服务器上运行相同的代码,运行正常没有任何问题。只有当我将代码部署到Heroku云时,它才会失败。应用程序中的所有其他URL似乎都可以正常工作。

2017-03-05T22:10:14.137989+00:00 heroku[router]: at=info method=GET path="/customer/programDetails?programInfoId=2" host=findraft.herokuapp.com request_id=01330e09-3db3-4994-994a-923c87bec9a1 fwd="107.15.104.213" dyno=web.1 connect=1ms service=4ms status=404 bytes=1183
2017-03-05T22:10:14.153199+00:00 app[web.1]: Mar 05, 2017 10:10:14 PM org.springframework.web.servlet.PageNotFound noHandlerFound
2017-03-05T22:10:14.153213+00:00 app[web.1]: WARNING: No mapping found for HTTP request with URI [/customer/programDetails] in DispatcherServlet with name 'dispatcher'

这是我的控制器:

    @RequestMapping("/programDetails")
    public String programDetails(@RequestParam(value = "programInfoId", required = false) Integer programInfoId, Model model){

        ProgramDetailsForm programDetailsForm = new ProgramDetailsForm();
        //update existing programInfo
        if(programInfoId != null){
            ProgramInfo programInfo = programInfoService.getProgramInfoById(programInfoId);

            programDetailsForm.setProgramInfo(programInfo);
            programDetailsForm.setBillingAddress(programInfo.getFiscalAgentAddress());
            programDetailsForm.setProgramSites(programInfo.getProgramSites());
        }
        //create new programInfo
        else {
            programDetailsForm.setBillingAddress(new BillingAddress());
            programDetailsForm.setProgramSites(new ArrayList<ProgramSite>());
        }

//        model.addAttribute("programInfo", programInfo);
        model.addAttribute("programDetailsForm", programDetailsForm);

        return "programDetails";
    }

    @RequestMapping(value = "/programDetails", method = RequestMethod.POST)
    public String programDetailsPost(@Valid @ModelAttribute("programDetailsForm") ProgramDetailsForm programDetailsForm,
                                     @RequestParam(value = "programInfoId", required = false) Integer programInfoId,
                                     HttpServletRequest request,
                                     BindingResult bindingResult, Model model){
        if(bindingResult.hasErrors()){
            return "programDetails";
        }

        if(programInfoId != null) {

            ProgramInfo programInfo = programDetailsForm.getProgramInfo();

            programInfo.setProgramSites(programInfoService.getProgramInfoById(programInfoId).getProgramSites());
            programInfo.setBudget(programInfoService.getProgramInfoById(programInfoId).getBudget());

            programInfo.setFiscalAgentAddress(programDetailsForm.getBillingAddress());
            BillingAddress billingAddress = programInfoService.getProgramInfoById(programInfoId).getFiscalAgentAddress();
            programInfo.getFiscalAgentAddress().setBillingAddressId(billingAddress.getBillingAddressId());
            CustomerAccount customerAccount = customerAccountService.getCustomerAccountById((Integer) request.getSession().getAttribute("customerAccountId"));
            programInfo.getFiscalAgentAddress().setCustomerAccount(customerAccount);
//        programInfo.getFiscalAgentAddress().setCustomerAccount(programInfo.getBudget().getCustomerAccount());
            billingAddressService.updateBillingAddress(programInfo.getFiscalAgentAddress());

            programInfo.setProgramInfoId(programInfoId);
            programInfoService.updateProgramInfo(programInfo);
        }
        else {
            ProgramInfo programInfo = programDetailsForm.getProgramInfo();
            BillingAddress fiscalAgentAddress = programDetailsForm.getBillingAddress();
            List<ProgramSite> programSites = new ArrayList<ProgramSite>();
            billingAddressService.addBillingAddress(fiscalAgentAddress);
            programInfo.setFiscalAgentAddress(fiscalAgentAddress);
            programInfo.setProgramSites(programSites);
            programInfoService.addProgramInfo(programInfo);
        }

//        return "redirect:/customer/programDetails?programInfoId=${programInfo.programInfoId}";
        return "redirect:/customer/managePrograms";
    }

非常感谢任何帮助。

0 个答案:

没有答案