type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception java.lang.NullPointerException
com.pet.action.Pupetinfo.PupetinfoAction.add(PupetinfoAction.java:97)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100) * 添加发布信息
 * @return
 * @throws IOException 
 */
public String add() throws IOException{

//添加数据库 Customer customer = (Customer) session.get("customer");
pu.setCustomer(customer);
System.out.println("ffffffffffff");
totalinfo = pupetinfoDao.querybycustomerId(customer.getCustomerId());//每天发布的免费信息数量
bymoney = pupetinfoDao.querybymoneyinfo(customer.getCustomerId());//发布的收费信息数量
totalinfos = pupetinfoDao.querybycustomerIdDay(customer.getCustomerId());//总共发布的免费信息数量

if(pu.getInfotype().getInfotypeId()==1){ //如果是免费信息
if(totalinfo==0){ //如果每天发布的信息为0
//插入数据库
pupetinfoDao.addPupetinfo(pu);

//积分加5
customer.setIntegral_1(customer.getIntegral_1()+5);
//金额不变
customerDao.update(customer);//更新用户
Date date = new Date();
Calendar cal = new GregorianCalendar(); 
Calendar cal1 = new GregorianCalendar(); 
Calendar cal2 = new GregorianCalendar(); 
cal.setTime(date);
cal1.setTime(pu.getPupetinfoTime());
cal2.setTime(pu.getEndinfoTime());
Accountinfo acc = new Accountinfo();
acc.setConsume(pu.getInfotype().getInfotypeId());//信息等级
acc.setContext(pu.getTitle());//描述
acc.setCustomerId(customer.getCustomerId());//用户ID
acc.setDatesum(cal2.getTime().getDate()-cal1.getTime().getDate());//花费时间
acc.setGetintegral(5);//获得的积分
acc.setSurplusdb(customer.getCusmoney());//剩下的钱
acc.setSurplusintegral(customer.getIntegral_1());//剩下的积分
accountinfoDao.save(acc);
return "input";
}
msg="你已经发布了一条免费信息了";
session.put("msg", msg);
表单:

解决方案 »

  1.   

     <div>
      <s:form action="add_add.action" method="post">
        <tr>

    <TD CLASS="tx" ><table id="infotype.infotypeId" onclick="infoTypeChang()" border="0" style="border-collapse:collapse; ">
    <TR >发布类型:<s:select name="pu.typeinfo" list="#{'出售':'出售','购买':'购买'}"  theme="simple"  listKey="key" listValue="value"/>
    <td >
    信息类型:<s:radio label="信息类型" id="rdl_InfoType_0"  name="infotype.infotypeId"    list="#{'4':'普通'}" value="4" theme="simple" listKey="key" listValue="value"/>
    <s:radio id="rdl_InfoType_2" name="infotype.infotypeId" list="#{'2':'Vip'}"   value="2" theme="simple"  listKey="key" listValue="value"/>
    <s:radio id="rdl_InfoType_3"  name="infotype.infotypeId" list="#{'3':'图片Vip'}"  value="3"  theme="simple"  listKey="key" listValue="value"/>
    <s:radio  id="rdl_InfoType_1" name="infotype.infotypeId"   list="#{'1':'免费'}"  value="1"  theme="simple"  listKey="key" listValue="value"/><span style="color: red; font-size: 9px;"><s:property value="#session.msg"/></span></td>

    <TR>
    </table>

    </TD>
    </tr>

    <tr id="tr_Property" style="display:none;">
    <TD CLASS="tx"  height="35">特性:
    <table id="rdl_Property"  >
    <tr>
    <td style="float: left;"><s:radio id="rdl_Property_0" name="infotype.typeinfo.typeinfoId"  list="#{'1':'无'}" theme="simple"/><s:radio id="rdl_Property_2" name="infotype.typeinfo.typeinfoId"  list="#{'3':'置顶'}" theme="simple"/><span style="color: red; font-size: 10px;">*默认置顶5天</span></td>
    </tr>
    </table>
    </TD>
    </tr>
    <tr id="tr_UploadPictrue" style="display:none; ">
    <TD CLASS="tx"  height="35">
    图片上传:
    <TD CLASS="tx" colspan="3"><table cellspacing="0" cellpadding="0"  border="0" style="width:150px;border-collapse:collapse;">
    <tr>
    <td><s:file name="file" theme="simple"/></td>
    </tr>
    </table></TD>
    <TR>
    </tr>
    <tr>
    <TD CLASS="tx" >
    宠物类型:<s:select name="petCategory.categoryId" theme="simple"  list="petcatelist" listKey="categoryId" listValue="goryname"/><br> <TD>
    </tr>
    <tr>
    <TD CLASS="tx" >
    信息标题:<s:textfield name="title" label="标题" theme="simple" size="50"/><span style="color: red; font-size: 10px;">*标题要长</span><br> <TD>
    </tr>
    <tr>

    <TD CLASS="tx" > 宠物名称:<s:textfield name="petname" theme="simple"/>
    <TD>
    <TD CLASS="tx" > 宠物妮称:<s:textfield name="petnickname" theme="simple"/>
    <TD>
    </tr>
    <tr>
    </tr>
    <tr>

    <TD CLASS="tx" > 宠物年龄:<s:select name="petage" theme="simple" list="#{'0':'0','1':'1','2':'2'}"/>
    <TD>
    <TD CLASS="tx" > 宠物颜色:<s:textfield name="petcolor" theme="simple"/>
    <TD>
    </tr>
    <tr>


    </tr>
    <tr>

    <TD CLASS="tx" > 宠物体重:<s:textfield name="petweight" theme="simple"/>
    <TD><TD CLASS="tx" > 宠物爱好:<s:textfield name="pethobby" theme="simple"/>
    <TD>
    </tr>
    <tr>


    </tr>
    <tr>

    <TD CLASS="tx" > 宠物性别:<s:radio name="petsex" theme="simple" list="#{'公':'公','母':'母'}"/>
    <TD>
    <TD CLASS="tx" > 宠物价格:<s:textfield name="price" theme="simple" />
    <TD>
    </tr>
    <tr>


    </tr>
    <tr>

    <TD CLASS="tx" > 结束时间:<s:textfield name="endinfoTime" theme="simple" id="datepicker" />

    <tr>

    <TD CLASS="tx" >
    <span style="color: red;font-size: 10">*<s:property value="#session.m"/></span>

    <TD>
    </tr>

    <TD>
    </tr>


    <s:submit value="确认发布"/> </s:form> 
    </div>
      

  2.   

    你自己测试呗,你先测试dao,到没事,你在测试action的属性的get方法,看能不能拿到数据,不能的话,那你页面的值没有传递过来,不是你页面属性名字写错了,就是你的实体类的属性写错了,
    我发现你宠物是个类,这里用了
    宠物类型:<s:select name="petCategory.categoryId" theme="simple" list="petcatelist",
    为什么
    宠物价格:<s:textfield name="price" theme="simple" />
    价格等没有用类的属性,而是直接用price
      

  3.   

    我那个price 就是属性 我后台有个实体对象 pu  这样是可以接收值的,我再一次提交就可以进行操作了
     我不清楚 第一次不可以的原因。
      

  4.   

    pu.setCustomer(customer);if(pu.getInfotype().getInfotypeId()==1){ //如果是免费信息
    pu是你new的一个对象吗?那你怎么pu.getInfotype=null .getInfotypeId 不会为空吗?
      

  5.   

    好像是第一次为空   private Pupetinfo pu = new Pupetinfo(); //对象实体
    怎么解决呢? 但是第二次是怎么能給值?(第二次提交可以)
      

  6.   

    还是谢谢您 提醒了我! 我有个到那个页面的方法 把pu=null 了, 把这个去掉就可以了,