我正在用Java开发我的网站.我正在使用jquery,ajax,像这样:
$.ajax({
dataType: "json",
url : 'getWords.htm',
type: 'post',
async : false,
data : {dataJSON : JSON.stringify(dataJSON)},
success : function(words) {
.....
}
});
Run Code Online (Sandbox Code Playgroud)
它运行良好,但在Chrome中它的工作速度比Firefox,IE和Opera慢.在Chrome中我有一点延迟(约0.8秒).当我每次点击四次ajax查询时,它真的很慢.我该如何解决?
在firebug我看到:发送5ms,等待512ms,接收3ms,但在其他浏览器中快速.
谢谢.
我使用mybatis在我的项目中执行sql查询.我需要在执行之前拦截sql查询以动态应用一些更改.我读过这样的@Interseptors:
@Intercepts({@Signature(type= Executor.class, method = "query", args = {...})})
public class ExamplePlugin implements Interceptor {
public Object intercept(Invocation invocation) throws Throwable {
return invocation.proceed();
}
public Object plugin(Object target) {
return Plugin.wrap(target, this);
}
public void setProperties(Properties properties) {
}
}
Run Code Online (Sandbox Code Playgroud)
它确实拦截了执行,但由于适当的字段不可写,因此无法更改sql查询.我应该手动构建整个对象的新实例来替换sql查询吗?拦截查询执行以动态更改它的正确位置在哪里?谢谢.
我需要执行在运行时由java代码生成的查询(不是静态方法).我已经知道如何使用注释和静态方法或使用xml mapper来构建动态查询,但它不适合我的情况.
有没有办法直接从java代码执行查询?