我無法從JSP獲取值到我的Spring控制器,下面是我的代碼片段。無法從jsp獲取參數到彈簧控制器
像<input type="hidden" id="categoryId" name="categoryId" value="<c:out value="${category.categoryId}"/>" />
<input type="hidden" id="sortBy" name="sortBy" value="<c:out value="${requestScope.sortBy}"/>" />
<input type="hidden" id="orderBy" name="orderBy" value="<c:out value="${requestScope.orderBy}"/>" />
在JSP
我已經定義的參數和我的控制器看起來像
@RequestMapping(value = "category/listCategory.htm")
public ModelAndView getList(HttpServletRequest request) {
long longCurrentPage = CommonUtils.checkPaginationAttributes(request);
String orderBy = request.getParameter(const_OrderBy);
String sortBy = request.getParameter(const_SortBy);
List<Category> categoryList = categoryService.getCategoryList(longCurrentPage, orderBy, sortBy);
...
...
...
request.setAttribute("currentPage", new Long(longCurrentPage));
request.setAttribute(const_OrderBy, orderBy);
request.setAttribute(const_SortBy, sortBy);
ModelAndView modelandView = new ModelAndView("listCategory","categoryList",categoryList);
從控制器到JSP值設定罰款,而從JSP得到相同的值越來越空的
我也試過
public ModelAndView getList(
@RequestParam(value = "orderBy", required = false, defaultValue = "") String orderBy,
@RequestParam(value = "sortBy", required = false, defaultValue = "") String sortBy,
@RequestParam(value = "oortBy", required = false, defaultValue = "") String oortBy,
@RequestParam(value = "isPaginationClicked", required = false, defaultValue = "") String isPaginationClicked,
@RequestParam(value = "currentPage", required = false, defaultValue = "") String currentPage)
個
不過我不是獲取值,
請幫助..在此先感謝...
您需要發佈整個jsp頁面才能看到問題出在哪裏。這會產生很多問題,也許你沒有附上輸入框的表單標籤。 – Zemzela 2014-11-03 15:04:09