0

jspページは次のとおりです。

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="kendo" uri="http://www.kendoui.com/jsp/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:url value="/web/grid/editing-popup/create.html" var="createUrl"/>
<c:url value="/web/grid/editing-popup/read.html" var="readUrl"/>
<c:url value="/web/grid/editing-popup/update.html" var="updateUrl"/>
<c:url value="/web/grid/editing-popup/destroy.html" var="destroyUrl"/>
<%--
  Created by IntelliJ IDEA.
  User: Rooyan
  Date: 5/26/13
  Time: 4:07 PM
  To change this template use File | Settings | File Templates.
--%>
<html>
<head>
    <link href="../../Styles/examples-offline.css" rel="stylesheet">
    <link href="../../Styles/kendo.common.min.css" rel="stylesheet">
    <link href="../../Styles/kendo.metro.min.css" rel="stylesheet">
    <link href="../../Styles/kendo.rtl.min.css" rel="stylesheet">

    <script src="../../Scripts/jquery.min.js"></script>
    <script src="../../Scripts/kendo.web.min.js"></script>
    <script src="../../Scripts/console.js"></script>
    <link href="../../Styles/Home.css" rel="stylesheet" type="text/css"/>
    <link href="../../Styles/Menu.css" rel="stylesheet" type="text/css"/>
    <link href="../../Styles/jquery-ui-1.10.0.custom.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="../../Scripts/jquery-ui-1.10.0.custom.js"></script>
    <title></title>
</head>
<body>
<kendo:grid name="students" sortable="true" selectable="true" scrollable="true"
            groupable="true"
            pageable="true" height="450" width="100">
    <kendo:grid-editable mode="popup"/>
    <kendo:grid-toolbar>
        <kendo:grid-toolbarItem name="create" text="ایجاد رکورد جدید"/>
    </kendo:grid-toolbar>
    <kendo:dataSource pageSize="10">
        <kendo:dataSource-transport>
            <kendo:dataSource-transport-read
                    url="${readUrl}" dataType="json" contentType="application/json" type="POST"/>
            <kendo:dataSource-transport-create
                    url="${createUrl}" dataType="json" contentType="application/json" type="POST"/>
            <kendo:dataSource-transport-update
                    url="${updateUrl}" dataType="json" contentType="application/json" type="POST"/>
            <kendo:dataSource-transport-destroy
                    url="${destroyUrl}" dataType="json" contentType="application/json" type="POST"/>
            <kendo:dataSource-transport-parameterMap>
                <script>
                    function parameterMap(options, type) {
                        return JSON.stringify(options);
                    }
                </script>
            </kendo:dataSource-transport-parameterMap>
        </kendo:dataSource-transport>
        <kendo:dataSource-schema>
            <kendo:dataSource-schema-model id="id">
                <kendo:dataSource-schema-model-fields>
                    <kendo:dataSource-schema-model-field name="firstName" type="string">
                        <kendo:dataSource-schema-model-field-validation required="true"/>
                    </kendo:dataSource-schema-model-field>
                    <kendo:dataSource-schema-model-field name="lastName" type="string">
                    </kendo:dataSource-schema-model-field>
                </kendo:dataSource-schema-model-fields>
            </kendo:dataSource-schema-model>
        </kendo:dataSource-schema>
    </kendo:dataSource>
    <kendo:grid-columns>
        <kendo:grid-column>
            <kendo:grid-column-command>
                <kendo:grid-column-commandItem name="edit" text="ویرایش"/>
            </kendo:grid-column-command>
        </kendo:grid-column>
        <kendo:grid-column field="firstName" title="نام" width="30%"/>
        <kendo:grid-column field="lastName" title="نام خانوادگی" width="40%"/>
        <kendo:grid-column>
            <kendo:grid-column-command>
                <kendo:grid-column-commandItem name="destroy" text="حذف"/>
            </kendo:grid-column-command>
        </kendo:grid-column>
    </kendo:grid-columns>
</kendo:grid>
</body>
</html>

ここに私のSpring MVCコントローラーがあります:

package Rooyan.controller;

import Rooyan.Interfaces.StudentService;
import com.google.gson.Gson;
import model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Rooyan
 * Date: 5/26/13
 * Time: 8:41 AM
 * To change this template use File | Settings | File Templates.
 */
@Controller("grid-editing-popup-controller")
@RequestMapping(value="/web/grid")
public class GridController {
    @Autowired
    StudentService studentService;

    @RequestMapping(value="/editing-popup", method = RequestMethod.GET)
    public String index() {
        return "hello";
    }


    @RequestMapping(value = "/editing-popup/read", method = RequestMethod.POST)
    public @ResponseBody List<Student> read() {
//        return studentService.getList();
        List<Student> lst = new ArrayList<Student>();
        Student std1 = new Student();
        Student std2 = new Student();
        Student std3 = new Student();

        std1.setId(1);
        std1.setFirstName("Ali");
        std1.setLastName("Mousavy");
        lst.add(std1);

        std2.setId(2);
        std2.setFirstName("Javad");
        std2.setLastName("Ahmadvand");
        lst.add(std2);

        std3.setId(3);
        std3.setFirstName("Aboutaleb");
        std3.setLastName("Hashemi");
        lst.add(std3);

        return lst;
    }

    @RequestMapping(value = "/editing-popup/update", method = RequestMethod.POST)
    public @ResponseBody Student update(@RequestBody Map<String, Object> model) {
        Student target = new Student();

        target.setFirstName((String)model.get("firstName"));
        target.setLastName((String)model.get("lastName"));

        studentService.UpdateEntity(target);
        return target;
    }

    @RequestMapping(value = "/editing-popup/create", method = RequestMethod.POST)
    public @ResponseBody Student create(@RequestBody Map<String, Object> model) {
        Student target = new Student();

        target.setFirstName((String)model.get("firstName"));
        target.setLastName((String)model.get("lastName"));

        studentService.InsertEntity(target);
        return target;
    }

    @RequestMapping(value = "/editing-popup/destroy", method = RequestMethod.POST)
    public @ResponseBody Student destroy(@RequestBody Map<String, Object> model) {
        Student target = new Student();

        target.setId(Integer.parseInt(model.get("id").toString()));

        studentService.DeleteEntity(target);

        return target;
    }




}

問題は、剣道のウェブサイトの例がこのコードを使用しているときにグリッドが空であることです

readurl は機能しませんが、作成 URL は正しく機能しています! 挿入ボタン (グリッド上) を押すと、新しいレコードを追加するためのポップアップ ウィンドウが表示され、そのボタンをクリックすると、データベースにレコードが挿入されます。

問題はどこだ?!

4

1 に答える 1