我很难根据参数通过来显示数据。 下面是我的代码。 下面是基于序列的代码。 我的问题是, 当调试时, 控制器通过到第二页 jsp, 它会检索到属于 proutId 的参数, 但是当它没有在 jsp 和 获取数据的控制器中显示数据时, 它会检索到该参数。 我知道我的问题很长, 但请帮助我。 第一页会显示可用的课程列表。 当用户单击课程时, 它会转到控制器 。
@RequestMapping(value="MregisteredClassesDetail.phone")
public final ModelAndView registeredClassesDetail(final HttpServletRequest request,
final HttpServletResponse response,HttpSession session) {
ModelAndView mav = new ModelAndView();
log.debug("Registered Classes Detail:");
log.debug("CourseId:"+request.getParameter("courseId"));
request.setAttribute("page", AlteraCommonConstant.DEFAULT_PAGE);
request.setAttribute("row", AlteraCommonConstant.DEFAULT_PAGE_SIZE);
request.setAttribute("courseId","courseId");
System.out.println(">>>>>>>>>>>>>>>> Registered Classes Detail");
mav.setViewName("mobile/MregisteredClassesDetail.jsp");
return mav;
}
然后它会转到jsp 第二页...
$( #MregisteredClassesDetails ).live( pageshow , function(){
var rowInput = "1";
var pageInput = "1";
var idInput = document.getElementById("courseId");
$.ajax({
url: ${pageContext.request.contextPath}/getRegisteredClassesDetails.html ,
data: ( {rows : rowInput , page : pageInput, courseId : idInput}),
type: POST ,
success: function(json_results){
$( #list ).append( <ul data-role="listview" data-inset="true"</ul> );
listItems = $( #list ).find( ul );
html = ################################################################################################# ;
html += <h1> +json_results.courseName+ </h1> ;
html += ################################################################################################# ;
html += <br> Registration # : +json_results.regNo+ </br> ;
html += <br> Status : +json_results.regStatus+ </br> ;
html += <br> Location : +json_results.courseLoc+ </br> ;
html += <br> Start Date : +json_results.startDate+ </br> ;
html += <br> Registered Person : +json_results.fullName+ </br> ;
html += <br> Rate : +json_results.rate+ </br> ;
listItems.append(html);
$( #list ul ).listview();
$.mobile.pageLoading(true);
}
});
});
html 和 html 和 html 和 html 和 html 和 html 和 html 和 html 和 html 和 html 和 html 和 html 和 html 和 html
<form name="ViewClassForm" method="POST">
<input name="courseId" type="hidden" value="${MregisteredClassesDetail.courseId}"/>
</form>
<div data-role="page" id="MregisteredClassesDetails" data-add-back-btn="true">
<div data-role="header" data-position="fixed" data-theme="b"><h1></h1>
</div><!-- /header -->
<div data-role="content">
<div id="courseDetail">
<ul data-role="listview" data-inset="true" id="list"></ul>
</div>
</div><!-- /content -->
然后它会返回到控制器以检索数据。..
@RequestMapping(value = "getRegisteredClassesDetails.html", method = RequestMethod.POST)
public @ResponseBody CustomPagedResultResponse getRegisteredClassesDetails(
HttpServletRequest request,HttpSession session) {
CustomPagedResultResponse paging = new CustomPagedResultResponse();
log.debug("getRegisteredClassesData.html:");
log.debug("rows:"+request.getParameter("rows"));
log.debug("courseId:"+request.getParameter("courseId"));
log.debug("page:"+request.getParameter("page"));
log.debug("sidx:"+request.getParameter("sidx"));
log.debug("sord:"+request.getParameter("sord"));
String page = request.getParameter("page");
int pageSize = new Integer(request.getParameter("rows")).intValue();
StringBuffer condition = new StringBuffer();
if (request.getParameter("sidx") != null && !request.getParameter("sidx").equals("")) {
condition.append(request.getParameter("sidx"));
condition.append(" ");
}
if (request.getParameter("sord") != null && !request.getParameter("sord").equals("")) {
condition.append(request.getParameter("sord"));
}
log.debug("condition: " + condition.toString());
log.debug("page:"+page);
log.debug("row:"+pageSize);
String courseType = "%";
UserProfile userProfile = (UserProfile)session.getAttribute("userProfile");
//////////////////////////////////////////////////////
// Retrieve Total Record first
///////////////////////////////////////////////////////
RegisteredClassesSearch search = new RegisteredClassesSearch();
search.setLanguage("ENU");
search.setLoginRowId(userProfile.getContactRowId());
search.setRegNo(null);
search.setAction("1");
search.setCourseType(courseType);
search.setPage(null);
search.setPageSize(null);
search.setOrderBy(null);
Integer recordCount = registeredClassesService.getTotalAccounts(search);
log.debug("*****Training Controller Total record:"+recordCount);
System.out.println("*****Training Controller Total record:"+recordCount);
//////////////////////////////////////////////////////
// Retrieve Total Record first
///////////////////////////////////////////////////////
if(recordCount>0){
System.out.println("******** Login Id:"+userProfile.getContactRowId());
System.out.println("******** Course Type:"+courseType);
System.out.println("******** Page Size:"+pageSize);
System.out.println("******** Page:"+page);
System.out.println("******** Order By:"+condition);
List<RegisteredClassesTest> registeredClassesView = registeredClassesService.getAccounts(search);
paging.setRows(registeredClassesView);
}else{
paging.setRows(null);
}
paging.setRecords(String.valueOf(recordCount));
paging.setPage(page);
int total = recordCount % pageSize == 0 ? recordCount / pageSize : recordCount / pageSize + 1;
paging.setTotal(String.valueOf(total));
return paging;
}