post提交表单,Controller根本进不去

jsp:

<form id="itemAddForm" class="itemForm" method="post">
    <table cellpadding="8"  border="1">
        <tr><td>商品类目:</td><td>
                <a href="javascript:void(0)" class="easyui-linkbutton selectItemCat">选择类目</a>
                <input type="hidden" name="cid" style="width: 280px;"></input></td></tr><tr>
            <td>商品标题:</td><td>
                <input class="easyui-textbox" type="text" id="title" name="title" data-options="required:true" style="width: 280px;"></input>
            </td></tr><tr><td>购入日期:</td><td>
                <input class="easyui-datebox" type="text" name="buydate" data-options="required:true"></input>
            </td></tr><tr><td>商品进价(J):</td><td>
                <input class="easyui-numberbox" type="text" name="buyprice" data-options="min:1,max:99999999,precision:0,required:true" />
            </td></tr><tr><td>日本国内运费(J):</td><td>
                <input class="easyui-numberbox" type="text" name="japanfareprice" data-options="min:1,max:99999999,precision:0,required:true" />
            </td></tr><tr><td>国际运费(J):</td><td>
                <input class="easyui-numberbox" type="text" name="interfareprice" data-options="min:1,max:99999999,precision:0,required:true" />
            </td></tr><tr><td>国内运费(C):</td><td>
                <input class="easyui-numberbox" type="text" name="chinafareprice" data-options="min:1,max:99999999,precision:0,required:true" />
            </td></tr><tr><td>关税(C):</td><td>
                <input class="easyui-numberbox" type="text" name="taxprice" data-options="min:1,max:99999999,precision:0,required:true" />
            </td></tr><tr><td>商品售价(C):</td><td>
                <input class="easyui-numberbox" type="text" name="sellprice" data-options="min:1,max:99999999,precision:0,required:true" />
            </td></tr>
        </table>
    <input type="hidden" name="itemParams"/>
</form>
<div style="padding:5px">
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">提交</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()">重置</a>
</div>

<script type="text/javascript">
        //ajax的post方式提交表单
        function submitForm(){
        $.post("/item/save",$("#itemAddForm").serialize(), function(data){
            if(data.status == 200){
                $.messager.alert('提示','新增商品成功!');
            }else{
                $.messager.alert('提示','新增商品失败!');
            }});
            }

    function clearForm(){
        $('#itemAddForm').form('reset');
        itemAddEditor.html('');
    }

Controller:

@Controller
@RequestMapping("/item")
public class ItemController {

@Autowired
private ItemService itemService;

@RequestMapping(value="/save",method=RequestMethod.POST)
@ResponseBody
public TaotaoResult createItem(TbItem item) {
    TaotaoResult result =  itemService.createItem(item);
    return result;
}}

pojo:

public class TbItem {
    private Long id;

    private String title;

    private Date buydate;

    private Integer buyprice;

    private Integer japanfareprice;

    private Integer interfareprice;

    private Integer chinafareprice;

    private Integer taxprice;

    private Integer sellprice;

    private Long cid;

    private Byte status;

    private Date created;

    private Date updated;

get。。。
set。。。
}

好几天了,提交form表单但是Controller就是进不去,不知道为什么?求大神帮忙看看,谢谢

查看全部
zsj753014
zsj753014
2019/04/24 22:40
  • spring
  • maven
  • ajax
  • jquery
  • eclipse
  • 点赞
  • 收藏
  • 回答
    私信

4个回复