刚接触ofbiz不久,现记录做登录时的问题,期间感谢这篇文章http://blog.csdn.net/hezhipin610039/article/details/24292095:
在
component://common/webcommon/WEB-INF/common-controller.xml 中有https的登录,但是没注意到,自己写了一个同名的http的
登录uri,结果使用ajax登录时,经常进入error方法,后面将http的uri改名字就好了.
项目中将http的端口改成了9696,文件为/framework/catalina/ofbiz-component.xml
后面在测试https登录,成功后跳转到http的一个uri,结果端口始终为8081,通过上面的文章找到了端口8081改成9696就好了.
假如访问app/control/main然后跳转到登录,ofbiz会登录之后继续请求main视图.在用ajax做登录的时候这一步也会使最终的结果
到error方法中.原来是:
if ("logout".equals(previousRequest) || "/logout".equals(previousRequest) || "login".equals(previousRequest) || "/login".equals(previousRequest) || "checkLogin".equals(previousRequest) || "/checkLogin".equals(previousRequest) || "/checkLogin/login".equals(previousRequest)) {
Debug.logWarning("Found special _PREVIOUS_REQUEST_ of [" + previousRequest + "], setting to null to avoid problems, not running request again", module);
} else {
if (Debug.infoOn()) Debug.logInfo
可以改成:
if ("logout".equals(previousRequest) || "/logout".equals(previousRequest) || "login".equals(previousRequest) || "/login".equals(previousRequest) || "checkLogin".equals(previousRequest)
|| "/checkLogin".equals(previousRequest) || "/checkLogin/login".equals(previousRequest)) {
Debug.logWarning("Found special _PREVIOUS_REQUEST_ of [" + previousRequest + "], setting to null to avoid problems, not running request again", module);
}else if("none".equals(nextRequestResponse.type) && "success".equals(nextRequestResponse.name) && "ajaxLogin".equals(requestMap.uri)){
System.out.println("专门为ajax的登录写的");
}else {
if (Debug.infoOn()) Debug.logInfo
增加一个判断让程序不继续请求其他视图.
当然也可以直接在error方法中判断是否成功来跳转页面,不过程序会将下个视图全部返回到页面,浪费流量,而且在error中跳转也不好