无法通过ajax调用显示从控制器收到的同一页面上的列表。 IllegalStateException异常

时间:2016-04-20 04:52:48

标签: java jquery ajax jsp spring-mvc

我正在尝试在从控制器获取的jsp(在其加载时)上显示一个列表。控制器由ajax调用,该列表也由ajax函数作为Json响应接收,但它给出了以下错误:

@Controller
@RequestMapping("/displaySurvey.htm")
public class DisplaySurveyController extends javax.servlet.http.HttpServlet {

@RequestMapping(method = RequestMethod.GET)
public @ResponseBody  ArrayList<SurveyQuestions>  submit(@RequestParam("name") String request)
        throws AdException {
    String surveyId = request.substring(request.lastIndexOf("=") + 1);


    try {
        SurveyDAO surveyDao = new SurveyDAO();
        ArrayList<SurveyQuestions> questionList = (ArrayList<SurveyQuestions>) surveyDao.getSurveyQuestions(surveyId);
        return questionList;

    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("Exception: " + e.getMessage());
        throw new AdException("Could not list the categories", e);

    }

}
}

但是,如果列表返回为空,则调用ajax函数的成功,因此问题围绕将arraylist作为响应返回。

以下是我的jsp:

<camelContext xmlns="http://camel.apache.org/schema/spring">
    <route id="firstRoute">
        <from uri="activemq:queue:test.queue" />
        <doTry>
            <to uri="bean:myBean?method=appendCamel(1,hell)" />
              <log message="TEST LOG" />
            <when>
                <simple>${in.body} == 'hi'</simple>
                <to uri="direct:nextRoute" />
            </when>
            <doCatch>
                <exception>java.lang.Exception</exception>
            </doCatch>
        </doTry>
        <to uri="stream:out" />
        <to uri="bean:myBean?method=appendCamel2(34)" />
        <to uri="stream:out" />
        <to uri="direct:nextRoute" />
    </route>

    <route>
        <from uri="direct:nextRoute" />
        <to uri="stream:out" />
    </route>
</camelContext>

控制器:

dates = (u'2015-06-23',u'2015-06-29')
df = df.set_index('received_date')
df.index = pd.DatetimeIndex(df.index)
df[dates[0]:dates[1]]

任何人都可以帮我这个。

0 个答案:

没有答案