当前位置: 代码迷 >> Java Web开发 >> 标签怎么传递参数啊?
  详细解决方案

标签怎么传递参数啊?

热度:377   发布时间:2007-08-20 15:37:43.0
标签怎么传递参数啊?

<html:link action="/deleteQuestion.do?questionId=${queslist.questionId} && userId=${queslist.kmsUser.userId}">delete</html:link>

上面的代码为什么不对?急,在线等

为什么会报这样的异常:

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: For input string: "3 "
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.NumberFormatException: For input string: "3 "
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
java.lang.Integer.parseInt(Integer.java:456)
java.lang.Integer.parseInt(Integer.java:497)
com.yourcompany.struts.action.DeleteQuestionAction.execute(DeleteQuestionAction.java:35)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.

[此贴子已经被作者于2007-8-20 17:48:34编辑过]

搜索更多相关主题的帖子: 参数  userId  The  queslist  questionId  

----------------解决方案--------------------------------------------------------

各位大侠们,都来帮帮忙吧,很急啊

会的:帮忙解决一下,万分感激

不会的:增加人气,让别人都进来帮忙,谢谢各位了。


----------------解决方案--------------------------------------------------------

root cause

java.lang.NumberFormatException: For input string: "3 "
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) //我觉得不是提交有问题,
java.lang.Integer.parseInt(Integer.java:456) //那个错误可能
java.lang.Integer.parseInt(Integer.java:497)
我觉得可能不是个那个link的问题,可能是提交给deleteQuestion.do的时候呀,questionId,userId这两个值你可能要转换
为int 类型,因为上面的错误提示说你的NumberFormatException有问题呀.在deleteQuestion.do里你对于数据操作是int 类型的,但是你提交的时候是一个string类型~,转换一下吧~


----------------解决方案--------------------------------------------------------

话是这样说没错,我也知道是这个问题,关键是怎么支转换呢?
<html:link action="/deleteQuestion.do?questionId=${queslist.questionId} && userId=${queslist.kmsUser.userId}">delete</html:link>
怎么把红色的部分转换为字串符?程序中有一个ActionForm,有两个字段questionId和userId为什么还是不能转换?
真是晕死?


----------------解决方案--------------------------------------------------------
问题解决了,
[CODE]<bean:define id="questionId" name="queslist" property="questionId"/>
<bean:define id="userId" name="queslist" property="kmsUser.userId"/>

<%

Map params = new HashMap();
params.put("questionId", questionId);
params.put("userId", userId);
pageContext.setAttribute("parameters", params);
%>[/CODE]
这样就OK了
----------------解决方案--------------------------------------------------------
<html:link action="/deleteQuestion.do?questionId=<%=queslist.kmsUser.userId>& userId=<%=queslist.kmsUser.userId%>">delete</html:link>


推荐改为
<a href="项目名"+"/deleteQuestion.do?questionId=<%=queslist.kmsUser.userId>& userId=<%=queslist.kmsUser.userId%>">delete</a>

----------------解决方案--------------------------------------------------------
struts标签里怎么还套用${}标签阿?

----------------解决方案--------------------------------------------------------
恩。这个传递参数确实很容易搞混掉。
----------------解决方案--------------------------------------------------------
  相关解决方案