想用一个超链接发送请求,同时传递参数。<a href="<%=path %>/user.do?command=applyInfoInquire?pageNo=1">未通过申请者</a>处理请求的相应方法为 public ActionForward applyInfoInquire(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
int page = Integer.parseInt((String)request.getParameter("pageNo")); //其他代码
……
}我没有在相应的form中配置pageNo,所以用的request.getParameter来获得参数,但是报"java.lang.NumberFormatException: null"的错误,也就是说applyInfoInquire方法中pageNo没有值,即超链接中的参数pageNo的值没有被传递过来。请问下,这是为什么?会和超链接中的两个问号有关系吗?要如何解决?ps:我试过在form中配置pageNo,然后用request.getAttribute来获取参数,出现同样的错误。
HttpServletRequest request, HttpServletResponse response)
throws Exception {
int page = Integer.parseInt((String)request.getParameter("pageNo")); //其他代码
……
}我没有在相应的form中配置pageNo,所以用的request.getParameter来获得参数,但是报"java.lang.NumberFormatException: null"的错误,也就是说applyInfoInquire方法中pageNo没有值,即超链接中的参数pageNo的值没有被传递过来。请问下,这是为什么?会和超链接中的两个问号有关系吗?要如何解决?ps:我试过在form中配置pageNo,然后用request.getAttribute来获取参数,出现同样的错误。
<a href="<%=path %>/user.do?command=applyInfoInquire?pageNo=1">未通过申请者</a> 这里搞错了吧?多个参数用“&”符号。你用的是“?”号,当然接受不到咯。
应该是这样子:<a href="<%=path %>/user.do?command=applyInfoInquire&pageNo=1">未通过申请者</a>
<action path="/user"
type="cn.edu.sjzri.title.action.UserAction"
name="userDynaForm"
scope="request"
parameter="command"
validate="true"
>
<forward ……/>
</action>
</action-mappings>
还有一个问题
拿到请求参数不是这个方法request.getAttribute
而是request.getParameter("title") 拿到请求参数
然后把url改过来应该就可以了吧
还有看你的写的action应该是有formbean的,你也可以把这个参数注入到这个formbean里