chris688
2017-12-20 04:49
采纳率: 16.7%
浏览 2.3k
已采纳

jsp页面向后台提交的数据如何转换类型

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ include file="/common/global.jsp"%>



查询列表 //添加 function toAdd(){ window.location='${path}/mj_car_statusManagerController/toAdd.do'; } //删除 function toRemove(){ var ids=getSelectedRowsIds('Mj_car_statusManagerList'); if(ids){ top.showConfirmDiaglog('提示','删除数据不可恢复,确定要删除吗?',function(){ //关闭事件 refleshData('Mj_car_statusManagerList'); },function(){ //确认事件 $.post('${path}/mj_car_statusManagerController/deleteById.do?ids='+ids,function(data){ var json=$.parseJSON(data); if(json.success){ top.showArtDiaglog('提示','删除成功',function(){ //关闭事件 refleshData('Mj_car_statusManagerList'); },function(){ //确定事件 top.closeDialog(); }); }else{ top.showArtDiaglog('提示','删除失败',function(){ //关闭事件 },function(){ //确定事件 top.closeDialog(); }); } }); }); }else{ top.showArtDiaglog('提示','请选择一条数据进行操作',null,function(){ top.closeDialog(); }); } } //编辑 function toEdit(){ var selected=getSelectedRowsArr('Mj_car_statusManagerList'); if(selected.length>0&&selected.length<2){ window.location='${path}/mj_car_statusManagerController/editById.do?id='+selected; }else{ //提示信息 top.showArtDiaglog('提示','请选择一条数据进行操作',null,function(){ top.closeDialog(); }); } } //查看 function toInfo(){ var selected=getSelectedRowsArr('Mj_car_statusManagerList'); if(selected.length>0&&selected.length<2){ window.location='${path}/mj_car_statusManagerController/findById.do?id='+selected; }else{ top.showArtDiaglog('提示','请选择一条数据进行操作',null,function(){ top.closeDialog(); }); } } //设置查询参数 function postQueryParams(params) { var queryParams = $("#searchForm").serializeObject(); queryParams.limit=params.limit; queryParams.offset=params.offset; return queryParams; } //查询列表 function queryList(){ $('#Mj_car_statusManagerList').bootstrapTable('refresh'); } function dataChange(){ var data; var carState=$('#carStatus').val(); if(carState=="正常"){ data=1; }else{ data=0; } queryList(); } function editById(id){ window.location='${path}/mj_car_statusManagerController/editById.do?id='+id; } //根据id删除 function deleteById(id){ top.showConfirmDiaglog('提示','删除数据不可恢复,确定要删除吗?',function(){ //关闭事件 refleshData('Mj_car_statusManagerList'); },function(){ //确认事件 $.post('${path}/mj_car_statusManagerController/deleteById.do?ids='+id,function(data){ var json=$.parseJSON(data); if(json.success){ top.showArtDiaglog('提示','删除成功',function(){ //关闭事件 refleshData('Mj_car_statusManagerList'); },function(){ //确定事件 top.closeDialog(); }); }else{ top.showArtDiaglog('提示','删除失败',function(){ //关闭事件 },function(){ //确定事件 top.closeDialog(); }); } }); }); } //根据id查看 function viewById(id){ window.location='${path}/mj_car_statusManagerController/findById.do?id='+id; } //操作工具栏 function operatorFormatter(value, row, index) { var operator=""; <shiro:hasPermission name="Mj_car_statusManager:edit"> operator+='<button class="btn btn-warning btn-round btn-xs" onclick="editById(\''+row.id+'\');"><i class="glyphicon glyphicon-pencil"></i> 修改</button>&nbsp;&nbsp;'; </shiro:hasPermission> <shiro:hasPermission name="Mj_car_statusManager:info"> operator+='<button class="btn btn-success btn-round btn-xs" onclick="viewById(\''+row.id+'\')"><i class="glyphicon glyphicon-list-alt"></i>详情</button>&nbsp;&nbsp;'; </shiro:hasPermission> <shiro:hasPermission name="Mj_car_statusManager:remove"> operator+='<button class="btn btn-danger btn-round btn-xs" onclick="deleteById(\''+row.id+'\')"><i class="glyphicon glyphicon-trash"></i>删除</button>'; </shiro:hasPermission> return operator; } //状态 function statusFormatters(value,row,index){ if(value=='0'){ return '<span>异常</span>'; }else if(value=='1'){ return '<span>正常</span>'; }else{ return ""; } }



<div class="rightinfo">
    <div>
        <form id="searchForm" name="searchForm"  method="post">
            <label>车辆状态描述:</label><input type="text" id="carStatus" name="carStatus" class="txtSearch">&nbsp;
            <input type="button" id="carStatus" class="btn btn-info btn-round" value="查询" onclick="dataChange()">&nbsp;&nbsp;
            <input type="button" class="btn btn-warning btn-round" value="重置" onclick="$('#searchForm')[0].reset();"> 
        </form>
    </div>
    <div id="toolbar" class="btn-group">
        <shiro:hasPermission name="Mj_car_statusManager:add">
            <button class="btn btn-info btn-round" onclick="toAdd();">
                <i class="glyphicon glyphicon-plus"></i>添加
            </button>
        </shiro:hasPermission>
        <shiro:hasPermission name="Mj_car_statusManager:edit">
            <button class="btn btn-warning btn-round" onclick="toEdit();">
                <i class="glyphicon glyphicon-pencil"></i> 修改
            </button>
        </shiro:hasPermission>
        <shiro:hasPermission name="Mj_car_statusManager:info">
            <button class="btn btn-success btn-round" onclick="toInfo()">
                <i class="glyphicon glyphicon-list-alt"></i>详情
            </button>
        </shiro:hasPermission>
        <shiro:hasPermission name="Mj_car_statusManager:remove">
            <button class="btn btn-danger btn-round" onclick="toRemove()">
                <i class="glyphicon glyphicon-trash"></i>删除
            </button>
        </shiro:hasPermission>
    </div>

    <table id="Mj_car_statusManagerList" data-toggle="table"
        data-url="${path}/mj_car_statusManagerController/list.do" data-pagination="true"
        data-side-pagination="server" data-cache="false" data-query-params="postQueryParams"
        data-page-list="[10, 15, 20, 30, 50,100]" data-method="post"
        data-show-refresh="true" data-show-toggle="true"
        data-show-columns="true" data-toolbar="#toolbar"
        data-click-to-select="true" data-single-select="false"
        data-striped="true" data-content-type="application/x-www-form-urlencoded">
        <thead>
            <tr>
                <th data-field="" data-checkbox="true"></th>
                <th data-field="carName">车辆名称概述</th>
                <th data-field="carStatus" data-formatter="statusFormatters">车辆状态描述</th>
                <th data-field="operator" data-formatter="operatorFormatter">操作</th>
            </tr>
        </thead>
    </table>
</div>


我想做一个查询,但是前台是显示文字:正常,异常,,,数据库存的是0,1代号,
问题是我现在提交的文字后台数据库也提取不了啊,如何做转换

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

12条回答 默认 最新

  • Q544471255 2017-12-20 05:15
    已采纳

    在你查询的地方,进行转换, 正常,异常,,,数据库存的是0,1代号, 转换成相应数字在查询就可以了。

    评论
    解决 无用
    打赏 举报
  • 查看更多回答(11条)

相关推荐 更多相似问题