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

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条回答

  • JPF1024 2017-12-20 05:15
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(11条)

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序