记录平台改造中的问题及解决方法

来源:互联网 发布:java 开源oa系统 编辑:程序博客网 时间:2024/06/08 19:57

问题情景:
在用bootstrap中的表格时,某一行由于内容过多导致表格布局被撑大,很丑,
先是限制td 的width为100px,不横向扩大,变为纵向,现在想实现纵向只展示一行,多余部分省略,
于是添加 style=”width:100px;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;”
发现不好用,于是寻找其他解决方案,找了一下午,将style中的width=100px去掉,发现省略生效
在table style 加style=”table-layout: fixed”
问题二:
在同一页面中加载2个angular的scope的值发现第二个加载不出来
解决办法:
angular.element(document).ready(function() {
// angular.bootstrap(document.getElementById(“nodeId”),[“pageNode”]);
angular.bootstrap(document.getElementById(“userId”),[“pageUser”]);
});

添加手动引导,userId为 控制器所在层级的id,pageUser为angular的module

–( )代表一个汉字

强大的过滤器

app.filter(‘trans’, function () {
return function (value, para) {
if (!value) return ”;
if(para==”1”){
if(value==”1”){ return ‘字符串’;}
else if(value==”2”){return ‘整数’;}
else if(value==”3”){return ‘日期’;}
else if(value==”4”){return ‘浮点数’;}
else if(value==”5”){return ‘IN字符串’;}
else if(value==”6”){return ‘IN整数’;}
}else if(para==”2”){
if(value==”1”) return ‘文本框’;
else return ‘下拉框’;
}else if(para==”3”){
if(value==”1”) return ‘必填’;
else return ‘非必填’;
}
}
});

关于后台返回json数据前台解析问题

写法一:Print(result);

写法二:response.setContentType(“text/x-json;charset=utf-8”);
response.getWriter().print(result.toString());

当使用写法一时,返回的data 需使用eval

而当使用写法二时,返回类型为json,不需要eval,若使用则程序不会继续往下执行。。。

改造项目中原来前端框架使用exts,请求传参,返回数据
改造时请求数据采用ajax,参数写在了url中,发现怎么调试参数也是乱码,查阅资料过程中发现get请求参数在url中,request.set字符
post方式参数存放在请求数据包的消息体中。get方式参数存放在请求数据包的请求行的
URI字段中,
以?开始以param=value&parame2=value2的形式附加在URI字段之后。而
request.setCharacterEncoding(charset);
只对消息体中的数据起作用,对于URI字段中的参数不起作用。

解决:把参数单独 作为data给ajax,而不是写道url中

花费一下午:

请求返回的是String字符串,直接在angular中的scope中 repeat,结果怎么也不显示,把String eval了一下显示了 。。

response.setContentType(“text/json;charset=UTF-8”);
原ext返回类型设置为text/json ,后angular和ajax方式请求失败,改为下列 text/html


js中if(document.getElementById(“id”).value){ 这里面代码会执行}
如果你想根据div value的值来在js中做判断,上面的写法是不对的,你应该写成if(document.getElementById(“id”).value==”false”) js中if(),括号有值即为真
1.编码问题,搜索时乱码

2.ServletActionContext.getResponse().setContentType(
“text/json;charset=UTF-8”);
ServletActionContext.getResponse().setHeader(“Cache-Control”,
“no-cache”);

response中设置返回数据类型是text/json时,ajax前台接收失败不成功,dataType改为:json也不行 ?????????????
一、
$(document).ready(function(){
var url = location.search; //获取url中”?”符后的字串
var theRequest = new Object();
if (url.indexOf(“?”) != -1) {
var str = url.substr(1);
strs = str.split(“&”);
strss = strs[1].split(“=”);
funccodes = strs[3].split(“=”);
var flagU = strss[1];
var funccode = funccodes[1];
document.getElementById(“flagU”).value=flagU;
document.getElementById(“funccodef”).value=funccode;
}

二、取多选框的值:
var obj1 = “.check1”;
var usercode = ”;
(obj).each(function(i){  
        if(
((obj1)[i]).is(“:checked”)){  
            usercode =
($(obj1)[i]).attr(“usercode”);
}
});

三、同一页面angular加载数据是,发现第二个ng-app不加载,决解方法:bootstrap引导:如下:
var app = angular.module(‘pageNode’, []);
app.controller(‘listNodeCtrl’, function(scope,http) {
http.post(‘listMenuShouQuan. action?&start=0&limit=15&nodecode=’)  
    .success(function (response) {  
    $scope.listNode = response.root;  
    var totalPage = response.totalProperty;  
    changePageNum1(totalPage,1);  
    });  
});  
var app1 = angular.module(‘pageUser’, []);  
app1.controller(‘listUserCtrl’, function(
scope, http) {http.post(‘listCopyUser.action?&usercode=&username=&start=0&limit=15’)
.success(function (response) {
$scope.listUser = response.root;
var totalPage = response.totalProperty;
changePageNum(totalPage,1);
});
});
angular.element(document).ready(function() {
// angular.bootstrap(document.getElementById(“nodeId”),[“pageNode”]);
angular.bootstrap(document.getElementById(“userId”),[“pageUser”]);
});

userId 为controller所在div的id;

四、针对url 传参乱码问题 decodeURI(ids[1]) location.search

$(“.flag”,window.top.document)[1].className=”flag”;
window.top.document.getElementById(“elename”).value=id;

var sel1 = “#datatype option[value=”+response.root[0].datatype+”]”;
var sel2 = “#ctrltype option[value=”+response.root[0].ctrltype+”]”;
var sel3 = “#ismust option[value=”+response.root[0].ismust+”]”;
var sel4 = “#islikefld option[value=”+response.root[0].islikefld+”]”;
(sel1).attr(selected,true);(sel2).attr(“selected”,true);
(sel3).attr(selected,true);(sel4).attr(“selected”,true);
特殊情况一: 需求中 的值为时间 如3:30:00 时 $(sel1) ,jquery获取不到 改成如下:
var sel2 = “#warnbegintime option[value=’”+response.data.warnbegintime+”’]”; 区别在于value加引号

五。直接在input中写checked=“false” 无效
document.getElementById(“myCheck”).checked=false

六。 (“#nodecode”).val(“<%=nSSRS.GetText(1,1)%>”);(“#nodename”).val(“<%=nSSRS.GetText(1,2)%>”);
(“#runscript”).val(“<%=nSSRS.GetText(1,3)%>”);  
    var nodetype=”<%=nodetype%>”;  
    if(nodetype==”1”)
(“#selectone”).selected=’selected’;
else if(nodetype==’0’) $(‘#selecttwo’).selected=’selected’;

阅读全文
0 0