I am writing a program, but i encounter a problem: when I refresh the jsp page, system will automatically resubmit the whole page, and i don\'t know how to avoid it, can so
Here is the solution
@RequestMapping(value="masterrulescreation")
protected ModelAndView masterrules(HttpServletRequest request, HttpServletResponse response) throws Exception {
try {
if(request.getParameter("ruleCode")!=null && request.getParameter("ruleCode")!="") //check the primary key is not null ,if goes for submission
{
request.setCharacterEncoding("UTF-8");
String xxx=request.getParameter("xxx");
S
boolean result=object.method(xxx);
String message="";//reurning a messgae is sucess
if(result==true)
{
message="Data Saved successfully";
}
else
{
message="Error while saving data";
}
return (new ModelAndView(getMasterrulescreation(),"message",message));
}
else //if no value in primary key redirect fresh page
{
return (new ModelAndView(getMasterrulescreation()));
}
}
catch (Exception e) {
e.printStackTrace();
return null;
}
}