I am new to Springs and I am stuck at passing data from jsp to controller What i have here is a listing page where user is allowed to click on the primary key and then that primary key should pass to controller for it to detect the incoming request of the user to view the page
I have my listing jsp as follows
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<style>
.tableimp {
margin-top: 150px;
}
</style>
</head>
<body>
<table align="center" border="1" class="tableimp">
<tr>
<th bgcolor="#2E64FE">USERNAME</th>
<!-- <td> </td> -->
<th bgcolor="#2E64FE">FIRSTNAME</th>
<!-- <td> </td> -->
<th bgcolor="#2E64FE">LASTNAME</th>
<!-- <td> </td> -->
<th bgcolor="#2E64FE">EMAIL</th>
<!-- <td> </td> -->
<th bgcolor="#2E64FE">USERID</th>
</tr>
<c:forEach items="${stkList}" var="maps">
<tr>
<td colspan="5"> </td>
</tr>
<tr>
<c:forEach items="${maps}" var="mapEntry">
<td align="center"> <c:choose>
<c:when test="${mapEntry.key eq 'userId'}">
<c:url var="userView" value="userView.do" />
<a href="<c:out value='userView.do?userId=${mapEntry.value}' />">${mapEntry.value}</a>
</c:when>
<c:otherwise>
${mapEntry.value}
</c:otherwise>
</c:choose></td>
</c:forEach>
</tr>
</c:forEach>
</table>
</body>
</html>
My Controller
@RequestMapping(value="/userView.do*", method=RequestMethod.GET)
public ModelAndView viewUser(HttpServletRequest request)
{
try{
//I need that userId Here somehow
}
catch(Exception e)
{
e.printStackTrace();
}
return new ModelAndView("form","",null);
}
}
Could anyone please give me a snippet how to achieve the task
My url gets append to browser as i want : localhost:8080/SpringMVC/userView.do?userId=1
I need this userId value in my controller thats it :)
c:outvalue.