Showing the URL of the view in the address bar, instead of the one of the action
@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
Use either
new ModelAndView(new RedirectView(patient1/patientDetail)).
Or
redirect:patient1/patientDetail
精彩评论