JSONResult不能初始化
各位大侠请帮忙看看我这是什么错误为什么JSONResult不能初始化严重: Servlet.service() for servlet default threw exception
java.lang.NoClassDefFoundError: Could not initialize class org.apache.struts2.json.JSONResult
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:85)
at
下面是我的Acton类
package com.mhua.dm.webtier;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.struts2.interceptor.ServletRequestAware;
import com.mhua.dm.domain.service.IMouldService;
import com.mhua.dm.domain.vo.DmDatasource;
import com.mhua.dm.domain.vo.DmMould;
import com.mhua.dm.domain.vo.DmPrograma;
import com.opensymphony.xwork2.ActionSupport;
public class MouldAction extends ActionSupport implements ServletRequestAware {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
*
*/
private IMouldService mouldService;
private DmMould mould;
private DmDatasource datasource;
private DmPrograma programa;
private List<DmMould> mouldList;
private HttpServletRequest request;
private String result;
public String getMouldIsShow(){
String isshow = request.getParameter("mouldIsshow");
if(isshow.equals("") && isshow.isEmpty()){
isshow = "0";
}
mould = new DmMould();
mould.setMouldIsshow(isshow);
mouldList = mouldService.findMoouldIsShow(mould,0);
if(mouldList.size() > 0){
Iterator<DmMould> it = mouldList.iterator();
JSONArray jaDmm = new JSONArray();
while(it.hasNext()){
DmMould dmm = it.next();
Map<String,Object> mapDmm = new HashMap<String,Object>();
mapDmm.put("id",String.valueOf(dmm.getMouldId()));
mapDmm.put("name",dmm.getMouldName());
mapDmm.put("img",dmm.getMouldImg());
mapDmm.put("number",dmm.getMouldNumber());
JSONObject jObject;
JSONArray jaDmp = new JSONArray();
if(dmm.getDmProgramas().size() > 0){
Iterator<DmPrograma> itprograma = dmm.getDmProgramas().iterator();
while(itprograma.hasNext()){
DmPrograma dmp = itprograma.next();
Map<String,String> mapDmp = new HashMap<String,String>();
mapDmp.put("pid",String.valueOf(dmp.getProgramaId()));
mapDmp.put("prank",dmp.getProgramaRank());
mapDmp.put("pname",dmp.getProgramaName());
JSONObject jpdmp = new JSONObject();
jpdmp = JSONObject.fromObject(mapDmp);
jaDmp.add(jpdmp);
}
mapDmm.put("programa",jaDmp.toString());
}else{
mapDmm.put("programa", "null");
}
jObject = JSONObject.fromObject(mapDmm);
jaDmm.add(jObject);
}
result = jaDmm.toString();
return SUCCESS;
}else{
result = null;
return SUCCESS;
}
} --------------------编程问答-------------------- java.lang.NoClassDefFoundError 找不到这个类啊!看看你包里没这个类啊!
有的话,试试new JSONReslut() 看看能不能成功。 --------------------编程问答-------------------- JSON包加入build path了吗 --------------------编程问答-------------------- 这个问题怎样解决的呢,我也遇到这个问题了?
补充:Java , Web 开发