日期:2014-05-17  浏览次数:20697 次

jsp页面出空指针异常
jsp

 <html:errors/>
<form action="createAnswers.do" method="post">
标题:<input name="atitle" type="text"><br><br>
内容:<textarea name="acontext" style="display:none"></textarea>
<IFRAME ID="eWebEditor1" src="edit/editor.html" frameborder="0"
scrolling="no" width="467" height="200"></IFRAME>
<br>
<input name="mid" type="hidden" value="<%=mid%>"><br><br>
验证:<input name="atitle" type="text"><img src="image.jsp"onclick= "this.src= 'image.jsp? '+(new Date()) "/><br><br>
<input type="submit" value="提交"><input type="reset" value="重置">
</form>
</body>


public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)throws Exception {
CreateAnswersForm createAnswersForm = (CreateAnswersForm) form;// TODO Auto-generated method stub
HttpSession session = request.getSession(false);
String username=(String)session.getAttribute("username");
int mid=Integer.parseInt(request.getParameter("mid"));
System.out.print("-------------"+mid);
String atitle=createAnswersForm.getAtitle();
String acontext=createAnswersForm.getAcontext();
//判断用户是否登录
if(username==null)
{
ActionMessages errors = new ActionMessages();
errors.add("username.null",new ActionMessage("username.null"));
super.saveErrors(request, errors);
return mapping.getInputForward();
}else{
//判断论坛用户信息是否完整
boolean flg=false;
flg=new BuserDAO().sleBuser(username);
if(flg)
{ //用户信息完整
Buser buser=null;
buser=new BuserDAO().selectBid(username);
int bbid=buser.getBbid();
//封装数据
Answers answers=new Answers();
answers.setAtitle(atitle);
answers.setAcontext(acontext);
buser.setBbid(bbid);
Messager m=new Messager();
m.setMid(mid);
answers.setBuser(buser);
answers.setMessager(m);
new AnswersDAO().insertAnswers(answers);
}else{
return mapping.findForward("bbslog");
}
}
// String 
return mapping.findForward("answer_list");
}

------解决方案--------------------
这个
String acontext=createAnswersForm.getAcontext();
打印看看
------解决方案--------------------
异常信息都不共享 谁能帮你啊
------解决方案--------------------
value="<%=mid%>" 应该是这里的问题吧,页面上好像都没有得到 mid 你如何使用这个 表达式 ?
前面加一句 <% String mid = (String)request.getParameter("mid")%> action 中传过来 
request.setParamter("mid");
------解决方案--------------------
顶!!!!!
再检查