关于NULL的问题
我想从一个页面跳转到另一个页面而且要带过去一个参数
<a href="zhaopin/addyingPin.jsp?zhaopinId=<bean:write name="zhaoPinList" property="zhaopinId"/>">发出应聘请求</a>
我在相应的ACTION里面也写了
Integer zhaopinID =Integer.parseInt(request.getParameter("zhaopinId"));
为什么提交时候出现
javax.servlet.ServletException: null
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
com.longxin.util.MyActionServlet.process(MyActionServlet.java:19)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NumberFormatException: null java.lang.Integer.parseInt(Integer.java:415)
java.lang.Integer.parseInt(Integer.java:497)
com.longxin.struts.action.zhaoPin.YingPinAction.execute(YingPinAction.java:52)
org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:106)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
com.longxin.util.MyActionServlet.process(MyActionServlet.java:19)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
------解决方案--------------------...你这样写当然是不行的
<a href="zhaopin/addyingPin.jsp?zhaopinId=<% zhaoPinList.getZhaopinId()%>">发出应聘请求 </a >
要用struts标签 就要下面这样
<html:link href="zhaopin/addyingPin.jsp" paramId="zhaopinId" paramName="zhaoPinList" paramProperty="zhaopinId">
paramId属性 相当于
<a href="zhaopin/addyingPin.jsp?zhaopinId= <bean:write name="zhaoPinList" property="zhaopinId"/ >" >发出应聘请求 </a > 中的/addyingPin.jsp?zhaopinId 这地方的 zhaopinId这名字
paramName="zhaoPinList"属性 相当于<a href="zhaopin/addyingPin.jsp?zhaopinId= <bean:write name="zhaoPinList" property="zhaopinId"/ >" >发出应聘请求 </a > 中的 你在页面保存数据的实体BEAN 也就是zhaoPinList
paramProperty="zhaopinId">属性 相当于<a href="zhaopin/addyingPin.jsp?zhaopinId= <bean:write name="zhaoPinList" property="zhaopinId"/ >" >发出应聘请求 </a >中的 实体BEAN 中的属性 也就是zhaopinId