小编jav*_*ser的帖子

值'0000-00-00'不能表示为java.sql.Date

我正在研究一些需要从数据库中提取数据的项目,我使用Spring MVC从DB构建模型来选择数据.

这是我的JSP页面的问题:

<form action="result" method="get" >
<table>
<thead>
<tr>
<th>Date to select:</th>
<th>Name to select:</th>
<th>Type to select:</th>
</tr>
</thead>

<tbody>
<tr>
<td><form:select  path="listOfDates">
<form:option value="NONE"> --SELECT--</form:option>
<form:options items="${listOfDates}"></form:options>
</form:select>
</td>  
<td><form:select  path="listOfInstitutionsNames">
<form:option value="NONE"> --SELECT--</form:option>
<form:options items="${listOfInstitutionsNames}"></form:options>
</form:select>
</td>
<td>
<form:select  path="listOfInstitutionsTypes">
<form:option value="NONE"> --SELECT--</form:option>
<form:options items="${listOfInstitutionsTypes}"></form:options>
</form:select>
</td>
</tr>
</tbody>

<tfoot>
<tr>
<td><input type="submit" value="???????"/></td>
</tr>
</tfoot>

</table>
</form>
Run Code Online (Sandbox Code Playgroud)

正如你可以看到我尝试使用<form:select>Spring标签库.
问题:
但是当它用这个控制器准备我的模型时:

@Controller
public class HomeController{ 

    @Autowired …
Run Code Online (Sandbox Code Playgroud)

java mysql hibernate spring-mvc java.util.date

11
推荐指数
3
解决办法
5万
查看次数

如何从<form:select> Spring MVC传递数据

我想和你分享我的问题.

我在jsp页面上构建并在我的页面上<form:select>使用它<form:select>在我请求页面时用来从数据库中提取和呈现数据search.jsp,用户必须选择一个:

<form action="result" method="get" >

    <table>

    <tr>
    <th>Date fro DB:</th>
    <td><form:select  path="listOfDates">
    <form:option value="NONE"> --SELECT--</form:option>
    <form:options items="${listOfDates}"></form:options>
    </form:select>
    </td>
    </tr>

    <tr>
    <th>Name of company from DB:</th>
    <td><form:select  path="listOfInstitutionsNames">
    <form:option value="NONE"> --SELECT--</form:option>
    <form:options items="${listOfInstitutionsNames}"></form:options>
    </form:select>
    </td>
    </tr>

    <tr>
    <th>Type of company from DB:</th>
    <td>
    <form:select  path="listOfInstitutionsTypes">
    <form:option value="NONE"> --SELECT--</form:option>
    <form:options items="${listOfInstitutionsTypes}"></form:options>
    </form:select>
    </td>
    </tr>

    <tr>
    <td><input type="submit" value="???????"/></td>
    </tr>

    </table>

    </form>
Run Code Online (Sandbox Code Playgroud)

我需要将用户选择的请求参数传递给我的控制器,这里是控制器的代码:

@Controller
public class HomeController{


    @Autowired
    private ControllerSupportClass controllerSupportClass; 


        @RequestMapping(value="/search", method=RequestMethod.GET)
        public String …
Run Code Online (Sandbox Code Playgroud)

model-view-controller spring jsp controller spring-mvc

10
推荐指数
1
解决办法
7万
查看次数

为什么不在List <Integer>上添加(String)传递给List参数抛出异常?

为什么可以插入StringList<Integer>在下面的代码?我有一个类将数字插入到整数列表中:

public class Main {    
    public static void main(String[] args) {        
        List<Integer> list = new ArrayList<Integer>();
        list.add(2);
        list.add(3);
        list.add(4);

        Inserter inserter = new Inserter();
        inserter.insertValue(list);
        System.out.print(list);        
    }
}
Run Code Online (Sandbox Code Playgroud)

然后,我有一个单独的类,其插入String到一个List,与所述数字串值"42":

public class Inserter {    
    void insertValue(List list)
    {
        list.add(new String("42"));
    }
}
Run Code Online (Sandbox Code Playgroud)

为什么编译器不会引发编译器错误,或者运行时抛出运行时异常,例如*CastException,当我添加String到整数列表时?另外,为什么System.out.print(list)产生如下的输出而不抛出任何异常?

[2, 3, 4, 42]
Run Code Online (Sandbox Code Playgroud)

允许所有这些发生的根本原因是什么?

java generics

8
推荐指数
1
解决办法
1316
查看次数

org.springframework.beans.NotReadablePropertyException:bean类的无效属性Bean属性不可读或具有无效的getter方法

Spring MVC对我来说是新手.我想有一些关于Spring MVC的例子的综合文献(甚至官方文档也不容易理解).

所以我面临的问题是:

Jun 15, 2013 2:42:36 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [appServlet] in context with path [/controller] threw exception [An exception occurred processing JSP page /WEB-INF/views/index.jsp at line 27

24: 
25: <form:form  commandName="creationDate" method="GET" action="add">
26: 
27: <form:label path="creationDate.ParticularDate">Particular Date</form:label>
28: <form:input path="creationDate.ParticularDate" />
29: 
30: <form:label path="creationDate.childGoSchoolDate">Child go to School</form:label>


Stacktrace:] with root cause
org.springframework.beans.NotReadablePropertyException: Invalid property 'creationDate' of bean class [edu.demidov.dom.CreationDate]: Bean property 'creationDate' is not readable or has an invalid getter method: Does …
Run Code Online (Sandbox Code Playgroud)

spring jsp spring-mvc

7
推荐指数
1
解决办法
6万
查看次数

jQuery添加到JSP页面

我有一个jQuery代码,我在互联网上找到,我想将它集成到我的jsp页面,我使用Spring表单标签.

这是jQuery代码:

(function ($) {
    //??? ?????????? select ? input    
    var id = "test",
        $id = $('#' + id),
        choices = $id.find('option').map(function (n, e) {
            var $e = $(e);
            return {
                id: $e.val(),
                text: $e.text()
            };
        }),
        width = $id.width(),
        realClass = $id.get(0).className,
        realId = $id.get(0).id,


        $input = $('<input>',{width: width});
    $id.after($input);
    $id.hide();
    $id.find('option').remove();
    //??????????

    $input.select2({
        query: function (query) {
            var data = {}, i;
            data.results = [];

            // ?????????? ?? ??? ??????

            if (query.term !== "") {
                data.results.push({
                    id: query.term, …
Run Code Online (Sandbox Code Playgroud)

javascript css jquery jsp spring-mvc

7
推荐指数
1
解决办法
8万
查看次数