简体   繁体   English

如何在整个struts项目中仅对1个站点重新启用自动完成支持?

[英]How can I reenable autocomplete support for just 1 site in my whole struts project?

since I'm trying to solve this problem for some days, I thought about giving you guys a chance. 由于我几天来一直试图解决这个问题,因此我想给你们一个机会。 The situation: 情况:

We're running a SAP Shop with Java Server Pages and Struts in background. 我们正在运行一个带有Java Server Pages和Struts后台的SAP Shop。 We had to disable the HTML Header setable Cache with: 我们必须使用以下命令禁用HTML标头可设置的缓存:

response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "0");

Now what I want to do seemed to us as a simple task but turned out to be more scientific than we expected. 现在,我想做的事情对我们来说似乎是一个简单的任务,但结果却比我们预期的更加科学。

We want to turn auto-complete for IE back on just for the login page. 我们只想为登录页面打开IE的自动完成功能。 What I and my colleague tried were simple approaches like resetting the header values to various "should be caching" values like 'public' with expirens tomorrow or sth. 我和我的同事尝试的是简单的方法,例如将标头值重置为各种“应该缓存”的值,例如“ public”值,明天或某日都将到期。 Neither did anything give us that auto-complete boxes in IE6 and up. IE6及更高版本中的自动完成框都没有给我们任何帮助。

So does anyone know a method for JUST ONE PAGE in a Struts system to turn the caching & as we think the autocomplete back on? 有人知道Struts系统中的“仅一页”打开缓存的方法吗?

I don't think autocomplete has anything to do with the caching response headers. 我认为自动完成与缓存响应标头没有任何关系。 autocomplete is on by default, and can be disabled on a specific form field using autocomplete="off" . 默认情况下,自动完成功能是打开的,可以使用autocomplete="off"在特定的表单字段上将其禁用。 If you have such an attribute in your login form fields, then just remove it. 如果您在登录表单字段中具有此类属性,则只需将其删除。

See How do you disable browser Autocomplete on web form field / input tag? 请参阅如何禁用Web表单字段/输入标签上的浏览器自动完成功能?

Okay by now I found the answer myself. 好吧,现在我自己找到了答案。 It seems easier when you talk about it, does it? 当您谈论它时似乎更容易,对吗?

So the problem was, that we used a javascript function to submit our login form site. 因此,问题在于,我们使用了javascript函数来提交登录表单网站。 But that's not how you should do it (say's microsoft). 但这不是您应该怎么做(例如微软)。 I heard a techcast some minutes ago about the internet explorer relying on suspicious buttons for implemented browser functionality. 几分钟前,我听到了一次技术广播,内容是有关Internet Explorer依靠可疑按钮来实现浏览器功能的。

Having heard that the answer was kind of clear in my head. 听说答案在我脑海中很清晰。 I head to submit over a button. 我要提交一个按钮。 Since we (HAVE TO!) use Javascript to submit, cause the button is only a styled div, I had to call a button click to show IE that we do a 'official' postback. 由于我们(必须使用!)使用Javascript提交,导致按钮仅是样式化的div,因此我不得不调用按钮单击以向IE表示我们进行了“官方”回发。

That's the code: 那是代码:

function submitLoginForm()
{
    var hiddenSubmitBtn = document.getElementById("hiddenSubmitButton");
    if(hiddenSubmitBtn.click) {
        hiddenSubmitBtn.click();
    } else {
        document.loginform.submit();
    }
    return false;
}

It now works fine. 现在可以正常工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM