0

报错截图如下:
clipboard.png

目前确认报错语句:

*JSONObject json = JSONObject.fromObject(map);
//map的类型声明:Map<String, Object> map = new HashMap<String, Object>();*
       
       

JSONaction类具体代码:

package com.yzpc.action;

import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import net.sf.json.JSONObject;
import org.apache.struts2.interceptor.ServletRequestAware;
import com.opensymphony.xwork2.ActionSupport;

import com.yzpc.biz.StuBiz;
import com.yzpc.bean.Stu;

public class JsonAction extends ActionSupport implements ServletRequestAware{
    private HttpServletRequest request;
    private String result;
    
    public void setServletRequest(HttpServletRequest arg0) {
        this.request = arg0;
    }
    public String getResult() {
        return result;
    }
    public void setResult(String result) {
        this.result = result;
    }
    
    public String infoAjax() {
        StuBiz stuBiz = new StuBiz();
        Stu stu = new Stu();
        try {
            String id = request.getParameter("stu_id");
            System.out.println(id);
            
            Map<String, Object> map = new HashMap<String, Object>();
            stu = stuBiz.getStuById(id);
            String stu_id = stu.getStu_id();
            String stu_name = stu.getStu_name();
            int age = stu.getAge();
            String sex = stu.getSex();
            String specialty = stu.getSpecialty();
            String email = stu.getEmail();
            String telephone = stu.getTelphone();
            
            map.put("stu_id", stu_id );
            map.put("stu_name", stu_name);
            map.put("age", age);
            map.put("sex", sex);
            map.put("telephone", telephone);
            map.put("email", email);
            map.put("specialty", specialty);
            
            System.out.println("准备将map转换为json类型");
            JSONObject json = JSONObject.fromObject(map);
            result = json.toString();
            
        }catch(Exception e) {
            e.printStackTrace();
        }
        return "info";
    }
    
}

浏览器客户端ajax由于action返回值失败也报错:
Failed to load resource: the server responded with a status of 500 ()

2018-04-23 提问
1 个回答
1

已采纳

异常贴全一点,NoClassDefFoundError 异常一般是少包或者包冲突。

撰写答案

推广链接