My controller is as follows
@Controller
@RequestMapping(value="/users")
@SessionAttributes("searchUsersDTO")
public class UserController {
@Autowired
private UserService usersService;
@RequestMapping
public String users(Model model){
model.addAttribute("searchUsersDTO", new SearchUsersDTO());
return "search_for_users_page";
}
@RequestMapping(value="/search",method=RequestMethod.GET)
public String search(@ModelAttribute SearchUsersDTO searchUsersDTO,Model model){
List<UserDetail> list=usersService.search(searchUsersDTO);
model.addAttribute("usersList", list);
return "users_list_page";
}
@RequestMapping(value="/edit",method=RequestMethod.GET)
public String edit(@RequestParam(value="userId") Integer userId,Model model){
UserDetail detail=usersService.fetchUserDetails(userId);
model.addAttribute("userDetails", detail);
return "users_edit_view";
}
@RequestMapping(value="/save",method=RequestMethod.POST)
public String save(UserDetailsDTO userDetailsDTO,Model model){
usersService.updateUserDetails(userDetailsDTO);
return "redirect:/users/search";
}
}
servlet mapping in web.xml
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<init-param>
<param-name>spring.profiles.active</param-name>
<param-value>dev</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Frist I will search for users. It will display list of users.
Then I will choose a user to edit,It will display edit view with all details of the user.
Then modify and save the details, which will call save method and after saving the details, should navigate back to search view.
Every thing is working fine. But after saving browser url is displaying as context/users/save
, but i required context/users/search
.
I figured out the cause of the issues. Need solution.
My users_edit_view
has included the jquery.mobile-1.3.2.min.js
and I tried after removing of this lib. Then its working as desired.
Don't know why its causing the issue. And how to solve it.