在地址栏中显示视图的 URL,而不是操作的 URL

发布于 2024-10-08 17:48:59 字数 1440 浏览 1 评论 0原文

@RequestMapping(value = "updatePatient", method = RequestMethod.POST)
public ModelAndView postUpdatePatientById(
        @ModelAttribute("patient") PatientForm patientForm,
        HttpSession session) {
    Long id = (Long) session.getAttribute("refId");
    if (id != 0 || id != null) {
        Patient patient1 = HospitalPatientHelper
                .getPatientFrom_PatientForm(patientForm);
        patientService.updatePatient(patient1, id);
        PatientService patientService) {
    Patient patient = patientService.getPatientById(id);
    ModelAndView mv;
    PatientForm patientForm = HospitalPatientHelper
            .getPatientForm_FromPatient(patient);
    List<Weight> weights = patientService.viewLast10RecordedWeight(patient);
    WeightTable weightTable = new WeightTable();
    List<WeightSummaryTable> summaryWeights = weightTable.summary(weights,
            patient.getHeight());
    mv = new ModelAndView("patient1/patientDetail");
    mv.addObject("patient", patientForm);
    mv.addObject("summaries", summaryWeights);
    mv.addObject("lastWeight", summaryWeights.get(0).getWeight());
    mv.addObject("bmi", summaryWeights.get(0).getBmi());
    return mv;
    } else {
        return new ModelAndView("patient1/patientDetail");
    }

}

页面成功显示,但 url 没有改变,意味着 url 没有显示地址 www.url.com/Patient1/PatientDetail.htm

并且我希望返回的视图地址也应该是也显示在网址中。

请帮我

@RequestMapping(value = "updatePatient", method = RequestMethod.POST)
public ModelAndView postUpdatePatientById(
        @ModelAttribute("patient") PatientForm patientForm,
        HttpSession session) {
    Long id = (Long) session.getAttribute("refId");
    if (id != 0 || id != null) {
        Patient patient1 = HospitalPatientHelper
                .getPatientFrom_PatientForm(patientForm);
        patientService.updatePatient(patient1, id);
        PatientService patientService) {
    Patient patient = patientService.getPatientById(id);
    ModelAndView mv;
    PatientForm patientForm = HospitalPatientHelper
            .getPatientForm_FromPatient(patient);
    List<Weight> weights = patientService.viewLast10RecordedWeight(patient);
    WeightTable weightTable = new WeightTable();
    List<WeightSummaryTable> summaryWeights = weightTable.summary(weights,
            patient.getHeight());
    mv = new ModelAndView("patient1/patientDetail");
    mv.addObject("patient", patientForm);
    mv.addObject("summaries", summaryWeights);
    mv.addObject("lastWeight", summaryWeights.get(0).getWeight());
    mv.addObject("bmi", summaryWeights.get(0).getBmi());
    return mv;
    } else {
        return new ModelAndView("patient1/patientDetail");
    }

}

the page shown sucessfully, but the url dosn't change, means the url is not showing the address www.url.com/patient1/patientDetail.htm

and i want that the returning view address should also be shown in the url too.

please help me

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

戒ㄋ 2024-10-15 17:48:59

使用

new ModelAndView(new RedirectView(patient1/patientDetail)).

redirect:patient1/patientDetail

Use either

new ModelAndView(new RedirectView(patient1/patientDetail)).

Or

redirect:patient1/patientDetail
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文