1

我有两个 html 列表框,我从数据库中填充一个选择框和一个多选框。我无法将列表对象返回到多选列表框中,而是出现错误。下面是我的代码:

列表框 1

这得到了集合并得到了很好的数据:

<form:select path=""
id="dbvictims" title="Victims Of Crime" class="victimLst">
<form:options items="${dbvictims.dbvictimList}"
itemValue="socialSecurityNumber" itemLabel="name" />
</form:select>

第二个列表框(多选)

<form:select
path="victims" id="victims" title="Victims Of Crime"
multiple="multiple" class="victimLst">
<form:options items="${victimList}"
itemValue="socialSecurityNumber" itemLabel="name" />
</form:select>

数据库

两个列表框都使用相同的 jdbc 函数来获取它们的数据,我在 List getVictimList() 中放置了一条消息,它甚至没有第二次进入该函数。当页面是 GET 时,它在视图显示之前从服务器返回时访问该函数,再次访问该函数以在第二个列表中显示设置数据。即使功能是分开的,同样的问题仍然存在。

 public List<Citizens> getVictimList() throws Exception{
        String sql ="SELECT socialSecurityNumber,UCASE(CONCAT(fname ,CONCAT(' ', lname)))as name FROM TBLCITIZENS WHERE citizenTypeId = 3";//victims - 3

        List<Citizens> victimList = new ArrayList<Citizens>();

        List<Map<String, Object>> rows = getJdbcTemplate().queryForList(sql);
        for(Map<String, Object> row :rows){
            Citizens acitizen = new Citizens();
            acitizen.setName((String)row.get("name"));
            acitizen.setSocialSecurityNumber((Integer)row.get("socialSecurityNumber"));
            victimList.add(acitizen);
        }
        return victimList;
    }

控制器:

如果使用 myVictimList 实例变量设置第二个列表框,则 html 不会被呈现并且页面为空白。

myVictimList.put("dbvictimList",this.citizenManager.getListOfVictims());

Map<String, Object> myVictimList = new HashMap<String, Object>();

//this gets set in a GET function - code above ist list box gets set before the second. The second gets set when return from the server after a POST

model.addAttribute("dbvictims", myVictimList);

model.addAttribute("victimList",this.crimeManager.getVictimList());

return new ModelAndView("crime_registration");

错误:

org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.StackOverflowError
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:972)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

root cause

java.lang.StackOverflowError    com.crimetrack.service.CrimeManager.getVictimList(CrimeManager.java:47)     com.crimetrack.service.CrimeManager.getVictimList(CrimeManager.java:47)     com.crimetrack.service.CrimeManager.getVictimList(CrimeManager.java:47) ........
19236 [http-bio-8084-exec-4] DEBUG org.springframework.web.context.support.XmlWebApplicationContext  - Publishing event in WebApplicationContext for namespace 'crimetrack-servlet': ServletRequestHandledEvent: url=[/crimeTrack/getCrime/8.htm]; client=[127.0.0.1]; method=[POST]; servlet=[crimetrack]; session=[null]; user=[null]; time=[156ms]; status=[failed: org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.StackOverflowError]
19236 [http-bio-8084-exec-4] DEBUG org.springframework.web.context.support.XmlWebApplicationContext  - Publishing event in Root WebApplicationContext: ServletRequestHandledEvent: url=[/crimeTrack/getCrime/8.htm]; client=[127.0.0.1]; method=[POST]; servlet=[crimetrack]; session=[null]; user=[null]; time=[156ms]; status=[failed: org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.StackOverflowError]

萤火虫

"NetworkError: 500 Internal Server Error - http://localhost:8084/crimeTrack/getCrime/8.htm"
4

0 回答 0