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

时间:2010-12-21 04:20:10

标签: spring jsp spring-mvc

@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");
    }

}

页面显示成功,但网址不会更改,表示网址未显示地址www.url.com/patient1/patientDetail.htm

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

请帮帮我

1 个答案:

答案 0 :(得分:1)

使用

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

redirect:patient1/patientDetail