public class SyGoodsAllServe extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); }
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8"); String gdpage=request.getParameter("pageno"); int pageno=0; try { pageno=Integer.parseInt(gdpage); } catch (Exception e) { pageno=0; } GoodsAllDao all=new GoodsAllDao(); if(pageno<=0){ pageno=1; } if(pageno>all.getTotalPage("tb_GoodsInfo")){ pageno=all.getTotalPage("tb_GoodsInfo"); } Pager pag=new Pager(all.goods(pageno),all.getTotalPage("tb_GoodsInfo")); request.setAttribute("pager", pag); request.getRequestDispatcher("../GoodsShowsy.jsp?pageno="+pageno).forward(request, response); }
方法里面有个参数,但是我不能做提交来获得参数,该怎么办?
没清楚你的问题,能叙述详细点吗
在访问的时候,可以直接访问Servlet 。来获取参数
只有一小段代码,很不容易找到你的问题出现在哪里, 是jsp页面有问题,还是servlet代码有问题,或者是web.xml中有问题。