2018-01-04 19:14
@小松 首先确认编辑器(eclipse)的文本文件编码格式是UTF-8,
其次确认项目的编码:
最后确认Tomcat的编码:URIEncoding="UTF-8"
修改tomcat服务器下的conf文件夹下的service.xml文件。
需要修改的地方1:
URIEncoding="UTF-8" port="8009" protocol="AJP/1.3" redirectPort="8443"/>
需要修改的地方2:URIEncoding="UTF-8" connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
2017-12-26 15:17
@fmpoffice
总结一下几个常用的:
model.remove("attrs1","attrs2");// 删除 多个键, 适用与删除少量不要的值。底层使用的是 map的remove
model.keep("attrs1","attrs2");// 保留需要的键, 适用与删除大量不要的值。底层使用的是 新建一个map拷贝值
model.put(model);//拷贝,不能写入数据库,可拷贝所有的键值。 底层使用的是 map的putAll
model._setAttrs(model);//拷贝,能写入数据库,只能拷贝数据库的键值(如果有其他字段,会抛出ActiveRecordException)。底层使用的是for (Entry e : attrs.entrySet()) set(e.getKey(), e.getValue());
2017-12-22 13:45
你是想这样 ?
@Override
public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
if ( target.indexOf('.') != -1 && target.contains("/files/") ) {
RenderManager.me().getRenderFactory().getFileRender(new File(target));
return;
}
next.handle(target, request, response, isHandled);
}
2017-12-21 09:26
方法一
拦截器
inv.getController().getResponse().addHeader("Access-Control-Allow-Origin", "*");//指定域名
--------------------------------------------------------------------------------
方法二
1, JFinal的Controller返回的时候如下:
这里的content就是我的Json字符串
renderJson("innerSignCallBack(" + content + ")");//跨域的请求,jsonp
2, 页面的Ajax如下:
var url = 'http://xxx.com/getJson';
$.ajax({
type : "get", //必须get,不填也行
url : url,
dataType : "jsonp",
jsonp:'innerSignCallBack', //服务器端获取回调函数名的key
jsonpCallback:'innerSignCallBack', //回调函数名
success:function(data) { //成功
alert('成功')
},
error : function(msg) {//失败
alert('失败');
}
});
3, 测试, 打完收工