GVKun编程网logo

如何在点击链接时创建iframe?(创建链接到本页的锚点的方法正确的事())

15

本篇文章给大家谈谈如何阻止tag的window.on,以及'beforeUnload'事件?的知识点,同时本文还将给你拓展AngularJS中window.onbeforeunload在路由中的等效项

本篇文章给大家谈谈如何阻止tag的window.on,以及'beforeUnload'事件?的知识点,同时本文还将给你拓展AngularJS中window.onbeforeunload在路由中的等效项、ASP.NET,jQuery,脏窗体和window.onbeforeunload、beforeunload事件、DOMContentLoaded, load, beforeunload, unload等相关知识,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

如何阻止tag的window.on('beforeUnload')事件?(tenta阻止所有cookie)

如何阻止tag的window.on('beforeUnload')事件?(tenta阻止所有cookie)

在我的项目中,当用户想要使用 X按钮 关闭窗口/选项卡时,我需要获取用户确认警报。

但是 window.on(’beforeUnload’) 也适用于 超链接 。如何阻止此leave page警报<a> tag

我的 JSP 将拥有

<a href="next.jsp" id="navigate"> click here </a>

我的 Jquery 将具有

$(document).ready(function(){    $(''#navigate'').on(''click'', function() {    stopNavigate(event);    });});function stopNavigate(event){       $(window).off(''beforeunload'', function(){    });}$(window).on(''beforeunload'', function(){    return ''Are you sure you want to leave?'';});$(window).on(''unload'', function(){    logout();});

我不希望leave message alert用户单击任何按钮links。我leave message alert只需要进行
窗口关闭操作

答案1

小编典典

$(document).ready(function () {
$(‘#navigate’).on(‘mouseenter’, stopNavigate)
.on(‘mouseout’, function () {
$(window).on(‘beforeunload’, windowBeforeUnload);
});

});function stopNavigate(event) {    $(window).off(''beforeunload'');}function windowBeforeUnload() {    return ''Are you sure you want to leave?'';}$(window).on(''beforeunload'', windowBeforeUnload);

AngularJS中window.onbeforeunload在路由中的等效项

AngularJS中window.onbeforeunload在路由中的等效项

常规JavaScript具有window.onbeforeunload。如何在具有HTML5路由的AngularJS中模拟相同内容?

有$ beforeRouteChange,但是据我所知,它不允许您取消该事件。

需要说明的是:window.onbeforeunload可用于离开页面导航,但不适用于页面内导航,例如,仅通过HTML5历史API从一个控制器转到另一个控制器。

ASP.NET,jQuery,脏窗体和window.onbeforeunload

ASP.NET,jQuery,脏窗体和window.onbeforeunload

在我的ASP.NET网络应用程序中,我尝试创建一种通用的方式来警告用户,在使用jQuery进行更改之前,先从表单导航.相当标准的东西,但经过大量的搜索,我还没有找到一种有效的技术.

这是我现在所在的:

addToPostBack = function(func) {
        var old__doPostBack = __doPostBack;
        if (typeof __doPostBack != 'function') {
            __doPostBack = func;
        } else {
            __doPostBack = function() {
                old__doPostBack();
                func();
            }
        }
    }

    var isDirty = false;

    $(document).ready(function() {
        addToPostBack(function() {
            alert("Postback detected.")
            clearDirty();
        });
        $(':input').bind("change select keydown",setDirty);
        window.onbeforeunload = function(e) {
            var msg = "You have unsaved changes. "
            if (isDirty == true) {
                var e = e || window.event;
                if (e) { e.returnValue = msg; }
                return msg;
            }
        };
    });

    setDirty = function() {isDirty = true;}

    clearDirty = function() {isDirty = false;}

只要警告用户不要离开就行了.问题是我在每个相同的页面回发上收到警告.我的表单上有许多可能会触发回发的内容:

>页面上有保存,取消和删除链接按钮
>页面上可能还有其他的linkbutton在同一页面上执行服务器端功能
>可能还有其他的控件,autopostback = true,它们也附有服务器端功能,但不会导致用户离开页面.

这些东西都不应该引起警告,因为用户没有离开页面.我的代码试图劫持addToPostBack(more details on that in this question)在发布之前清除isDirty位,但问题是在IE onbeforeunload在__doPostBack之前触发,显然是因为当点击链接时,IE会立即触发onb​​eforeunload(as described here).

当然,我可以连接每个这些控件以清除isDirty位,但是我更喜欢在表单级别上运行的解决方案,并且不需要我触摸可能触发回发的每个控件.

有没有人有一种在ASP.NET中工作的方法,并且不涉及每个可能导致回发的控件的布线?

解决方法

我碰到这个帖子,而谷歌在一个解决方案做同样的事情在MVC.这个解决方案,从Herb的上面改编,似乎运作良好.由于没有关于MVC的具体内容,因此对于PHP,Classic ASP或使用HTML和JQuery的任何其他类型的应用程序来说,它也应该是一样的.
var isDirty = false;

$(document).ready(function () {
    $(':input').bind("change select keydown",setDirty);
    $('form').submit(clearDirty);

    window.onbeforeunload = function (e) {
        var msg = "You have unsaved changes. "
        if (isDirty == true) {
            var e = e || window.event;
            if (e) { e.returnValue = msg; }
            return msg;
        }
    };
});

setDirty = function () { isDirty = true; }
clearDirty = function () { isDirty = false; }

beforeunload事件

beforeunload事件

window.addEventListener("beforeunload", function (e) {
            var confirmationMessage = "\o/";

            (e || window.event).returnValue = confirmationMessage;     // Gecko and Trident
            return confirmationMessage;                                // Gecko and WebKit
        });

 

 

从2011年5月25号开始,HTML5规范指出在此事件处理函数中,对于window.alert()window.confirm(), 和 window.prompt() 的调用会被忽略。详见HTML5规范说明。

同样需要注意的是许多手机浏览器会忽略该事件处理的返回值(亦即,它们不会要求用户确认,而是直接执行操作)Firefox在about:config中有一个隐藏的设置来做同样的事。其实就是用户确认文档总会被卸载。

 经常会有一些在用户离开页面前执行一些业务的应用场景,这都要用到onbeforeunload事件

DOMContentLoaded, load, beforeunload, unload

DOMContentLoaded, load, beforeunload, unload

原文连接:https://javascript.info/onload-ondomcontentloaded

The lifecycle of an HTML page has three important events:

  • DOMContentLoaded – the browser fully loaded HTML,and the DOM tree is built,but external resources like pictures <img> and stylesheets may be not yet loaded.
  • load – not only HTML is loaded,but also all the external resources: images,styles etc.
  • beforeunload/unload – the user is leaving the page.

Each event may be useful:

  • DOMContentLoaded event – DOM is ready,so the handler can lookup DOM nodes,initialize the interface.
  • load event – external resources are loaded,so styles are applied,image sizes are kNown etc.
  • beforeunload event – the user is leaving: we can check if the user saved the changes and ask them whether they really want to leave.
  • unload – the user almost left,but we still can initiate some operations,such as sending out statistics.

Let’s explore the details of these events.

DOMContentLoaded

The DOMContentLoaded event happens on the document object.

We must use addEventListener to catch it:

document.addEventListener("DOMContentLoaded", ready);
// not "document.onDOMContentLoaded = ..."

For instance:










<script>
  function ready() {
    alert('DOM is ready');

    // image is not yet loaded (unless was cached),so the size is 0x0
    alert(`Image size: ${img.offsetWidth}x${img.offsetHeight}`);
  }

  document.addEventListener("DOMContentLoaded", ready);
</script>

<img id="img" src="https://en.js.cx/clipart/train.gif?speed=1&cache=0">

In the example the DOMContentLoaded handler runs when the document is loaded,so it can see all the elements,including <img> below.

But it doesn’t wait for the image to load. So alert shows zero sizes.

At the first sight DOMContentLoaded event is very simple. The DOM tree is ready – here’s the event. There are few peculiarities though.

DOMContentLoaded and scripts

When the browser processes an HTML-document and comes across a <script> tag,it needs to execute before continuing building the DOM. That’s a precaution,as scripts may want to modify DOM,and even document.write into it,so DOMContentLoaded has to wait.

So DOMContentLoaded definitely happens after such scripts:

<script>
  document.addEventListener("DOMContentLoaded", () => {
    alert("DOM ready!");
  });
</script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.3.0/lodash.js"></script>

<script>
  alert("Library loaded,inline script executed");
</script>

In the example above,we first see “Library loaded…”,and then “DOM ready!” (all scripts are executed).

Scripts with asyncdefer or type="module" don’t block DOMContentLoaded

Script attributes async and defer,that we’ll cover a bit later,don’t block DOMContentLoaded. JavaScript modules behave like defer,they don’t block it too.

So here we’re talking about “regular” scripts,like <script>...</script>,or <script src="..."></script>.

DOMContentLoaded and styles

External style sheets don’t affect DOM,so DOMContentLoaded does not wait for them.

But there’s a pitfall. If we have a script after the style,then that script must wait until the stylesheet loads:

<link type="text/css" rel="stylesheet" href="style.css">
<script>
  // the script doesn't not execute until the stylesheet is loaded
  alert(getComputedStyle(document.body).marginTop);
</script>

The reason is that the script may want to get coordinates and other style-dependent properties of elements,like in the example above. Naturally,it has to wait for styles to load.

As DOMContentLoaded waits for scripts,it Now waits for styles before them as well.

Built-in browser autofill

Firefox,Chrome and Opera autofill forms on DOMContentLoaded.

For instance,if the page has a form with login and password,and the browser remembered the values,then on DOMContentLoaded it may try to autofill them (if approved by the user).

So if DOMContentLoaded is postponed by long-loading scripts,then autofill also awaits. You probably saw that on some sites (if you use browser autofill) – the login/password fields don’t get autofilled immediately,but there’s a delay till the page fully loads. That’s actually the delay until the DOMContentLoaded event.

window.onload

The load event on the window object triggers when the whole page is loaded including styles,images and other resources.

The example below correctly shows image sizes,because window.onload waits for all images:

<script>
  window.onload = function() {
    alert('Page loaded');

    // image is loaded at this time
    alert(`Image size: ${img.offsetWidth}x${img.offsetHeight}`);
  };
</script>

<img id="img" src="https://en.js.cx/clipart/train.gif?speed=1&cache=0">

window.onunload

When a visitor leaves the page,the unload event triggers on window. We can do something there that doesn’t involve a delay,like closing related popup windows.

The notable exception is sending analytics.

Let’s say we gather data about how the page is used: mouse clicks,scrolls,viewed page areas,and so on.

Naturally, unload event is when the user leaves us,and we’d like to save the data on our server.

There exists a special navigator.sendbeacon(url,data) method for such needs,described in the specification https://w3c.github.io/beacon/.

It sends the data in background. The transition to another page is not delayed: the browser leaves the page,but still performs sendbeacon.

Here’s how to use it:

let analyticsData = { /* object with gathered data */ };

window.addEventListener("unload", function() {
  navigator.sendbeacon("/analytics", JSON.stringify(analyticsData));
};
  • The request is sent as POST.
  • We can send not only a string,but also forms and other formats,as described in the chapter Fetch,but usually it’s a stringified object.
  • The data is limited by 64kb.

When the sendbeacon request is finished,the browser probably has already left the document,so there’s no way to get server response (which is usually empty for analytics).

There’s also a keepalive flag for doing such “after-page-left” requests in fetch method for generic network requests. You can find more information in the chapter Fetch API.

If we want to cancel the transition to another page,we can’t do it here. But we can use another event – onbeforeunload.

window.onbeforeunload

If a visitor initiated navigation away from the page or tries to close the window,the beforeunload handler asks for additional confirmation.

If we cancel the event,the browser may ask the visitor if they are sure.

You can try it by running this code and then reloading the page:

window.onbeforeunload = function() {
  return false;
};

For historical reasons,returning a non-empty string also counts as canceling the event. Some time ago browsers used show it as a message,but as the modern specification says,they shouldn’t.

Here’s an example:

window.onbeforeunload = function() {
  return "There are unsaved changes. Leave Now?";
};

The behavior was changed,because some webmasters abused this event handler by showing misleading and annoying messages. So right Now old browsers still may show it as a message,but aside of that – there’s no way to customize the message shown to the user.

readyState

What happens if we set the DOMContentLoaded handler after the document is loaded?

Naturally,it never runs.

There are cases when we are not sure whether the document is ready or not. We’d like our function to execute when the DOM is loaded,be it Now or later.

The document.readyState property tells us about the current loading state.

There are 3 possible values:

  • "loading" – the document is loading.
  • "interactive" – the document was fully read.
  • "complete" – the document was fully read and all resources (like images) are loaded too.

So we can check document.readyState and setup a handler or execute the code immediately if it’s ready.

Like this:

function work() { /*...*/ }

if (document.readyState == 'loading') {
  // loading yet,wait for the event
  document.addEventListener('DOMContentLoaded', work);
} else {
  // DOM is ready!
  work();
}

There’s also readystatechange event that triggers when the state changes,so we can print all these states like this:

// current state
console.log(document.readyState);

// print state changes
document.addEventListener('readystatechange', () => console.log(document.readyState));

The readystatechange event is an alternative mechanics of tracking the document loading state,it appeared long ago. Nowadays,it is rarely used.

Let’s see the full events flow for the completeness.

Here’s a document with <iframe><img> and handlers that log events:

<script>
  log('initial readyState:' + document.readyState);

  document.addEventListener('readystatechange', () => log('readyState:' + document.readyState));
  document.addEventListener('DOMContentLoaded', () => log('DOMContentLoaded'));

  window.onload = () => log('window onload');
</script>

<iframe src="iframe.html" onload="log('iframe onload')"></iframe>

<img src="http://en.js.cx/clipart/train.gif" id="img">
<script>
  img.onload = () => log('img onload');
</script>

The working example is in the sandbox.

The typical output:

  1. [1] initial readyState:loading
  2. [2] readyState:interactive
  3. [2] DOMContentLoaded
  4. [3] iframe onload
  5. [4] img onload
  6. [4] readyState:complete
  7. [4] window onload

The numbers in square brackets denote the approximate time of when it happens. Events labeled with the same digit happen approximately at the same time (± a few ms).

  • document.readyState becomes interactive right before DOMContentLoaded. These two things actually mean the same.
  • document.readyState becomes complete when all resources (iframe and img) are loaded. Here we can see that it happens in about the same time as img.onload (img is the last resource) and window.onload. Switching to complete state means the same as window.onload. The difference is that window.onloadalways works after all other load handlers.

Summary

Page load events:

  • DOMContentLoaded event triggers on document when DOM is ready. We can apply JavaScript to elements at this stage.
    • Script such as <script>...</script> or <script src="..."></script> block DOMContentLoaded,the browser waits for them to execute.
    • Images and other resources may also still continue loading.
  • load event on window triggers when the page and all resources are loaded. We rarely use it,because there’s usually no need to wait for so long.
  • beforeunload event on window triggers when the user wants to leave the page. If we cancel the event,browser asks whether the user really wants to leave (e.g we have unsaved changes).
  • unload event on window triggers when the user is finally leaving,in the handler we can only do simple things that do not involve delays or asking a user. Because of that limitation,it’s rarely used. We can send out a network request with navigator.sendbeacon.
  • document.readyState is the current state of the document,changes can be tracked in the readystatechange event:
    • loading – the document is loading.
    • interactive – the document is parsed,happens at about the same time as DOMContentLoaded,but before it.
    • complete – the document and resources are loaded,happens at about the same time as window.onload,but before it.

Comments

关于如何阻止tag的window.on'beforeUnload'事件?的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于AngularJS中window.onbeforeunload在路由中的等效项、ASP.NET,jQuery,脏窗体和window.onbeforeunload、beforeunload事件、DOMContentLoaded, load, beforeunload, unload的相关信息,请在本站寻找。

这篇文章主要围绕JSP中是否有与java @SuppressWarnings等效的文件jsp如何与javabean结合?二者如何传递消息?展开,旨在为您提供一份详细的参考资料。我们将全面介绍JSP中是否有与java @SuppressWarnings等效的文件的优缺点,解答jsp如何与javabean结合?二者如何传递消息?的相关问题,同时也会为您带来@SuppressWarnings、@SuppressWarnings () java warning 警告、@SuppressWarnings 忽略警告、@SuppressWarnings 注解的实用方法。

本文目录一览:

JSP中是否有与java @SuppressWarnings等效的文件(jsp如何与javabean结合?二者如何传递消息?)

JSP中是否有与java @SuppressWarnings等效的文件(jsp如何与javabean结合?二者如何传递消息?)

问题在标题中:“ JSP中是否有等效于java @SuppressWarnings的东西?”

答案1

小编典典

是的,只需使用:

<%! @SuppressWarnings("unchecked") %>

@SuppressWarnings

@SuppressWarnings

具体可在 eclipse 中当代码有黄色下划线时通过 Ctrl+1来观察需要加上什么参数的 suppresswarnings 以及不同参数的区别

通过 @SuppressWarnings (压制注解)的源码可知,其注解目标为类、字段、函数、函数入参、构造函数和函数的局部变量。 通常情况下建议注解应声明在最接近警告发生的位置。

@SuppressWarnings("unchecked") @SuppressWarnings(value={"unchecked", "rawtypes"})

deprecation 使用了不赞成使用的类或方法时的警告 unchecked 执行了未检查的转换时的警告,例如当使用集合时没有用泛型 (Generics) 来指定集合保存的类型。如:List<String> list = doSometing (); doSometing 返回的是 List<Object>,但是你知道是 List<String> path 在类路径、源文件路径等中有不存在的路径时的警告。 serial 当在可序列化的类上缺少 serialVersionUID 定义时的警告。 finally 任何 finally 子句不能正常完成时的警告。

这里输入引用文本这里是列表文本 all to suppress all warnings(所有警告)

boxing to suppress warnings relative to boxing/unboxing operations(装箱、拆箱)

cast to suppress warnings relative to cast operations(转换操作)

dep-ann to suppress warnings relative to deprecated annotation(过时的 annotation)

deprecation to suppress warnings relative to deprecation (过时)

fallthrough to suppress warnings relative to missing breaks in switch statements(switch 无 break)

finally to suppress warnings relative to finally block that don’t return

hiding to suppress warnings relative to locals that hide variable

incomplete-switch to suppress warnings relative to missing entries in a switch statement (enum case)(枚举时不完整的 switch)

nls to suppress warnings relative to non-nls string literals

null to suppress warnings relative to null analysis

rawtypes to suppress warnings relative to un-specific types when using generics on class params

restriction to suppress warnings relative to usage of discouraged or forbidden references

serial to suppress warnings relative to missing serialVersionUID field for a serializable class(无序列化 id)

static-access to suppress warnings relative to incorrect static access

synthetic-access to suppress warnings relative to unoptimized access from inner classes

unchecked to suppress warnings relative to unchecked operations

unqualified-field-access to suppress warnings relative to field access unqualified

unused to suppress warnings relative to unused code(未使用)

@SuppressWarnings () java warning 警告

@SuppressWarnings () java warning 警告

1. @SuppressWarnings("unchecked")  [^ 抑制单类型的警告]
2. @SuppressWarnings("unchecked","rawtypes") [^ 抑制多类型的警告] 3. @SuppressWarnings("unchecked") [^ 抑制所有类型的警告] *** > 通过源码分析可知@SuppressWarnings其注解目标为类、字段、函数、函数入参、构造函数和函数的局部变量。建议把注解放在最近进警告发生的位置。 下面列举警告关键字:
关键字 用途
all to suppress all warnings (抑制所有警告)
boxing to suppress warnings relative to boxing/unboxing operations (抑制装箱、拆箱操作时候的警告)
cast to suppress warnings relative to cast operations (抑制映射相关的警告)
dep-ann to suppress warnings relative to deprecated annotation (抑制启用注释的警告)
deprecation to suppress warnings relative to deprecation (抑制过期方法警告)
fallthrough to suppress warnings relative to missing breaks in switch statements (抑制确在 switch 中缺失 breaks 的警告)
finally to suppress warnings relative to finally block that don’t return (抑制 finally 模块没有返回的警告)
hiding to suppress warnings relative to locals that hide variable(抑制相对于隐藏变量的局部变量的警告)
incomplete-switch to suppress warnings relative to missing entries in a switch statement (enum case)(忽略没有完整的 switch 语句)
nls to suppress warnings relative to non-nls string literals( 忽略非 nls 格式的字符)
null to suppress warnings relative to null analysis( 忽略对 null 的操作)
rawtypes to suppress warnings relative to un-specific types when using generics on class params( 使用 generics 时忽略没有指定相应的类型)
restriction to suppress warnings relative to usage of discouraged or forbidden references( 抑制禁止使用劝阻或禁止引用的警告)
serial to suppress warnings relative to missing serialVersionUID field for a serializable class( 忽略在 serializable 类中没有声明 serialVersionUID 变量)
static-access to suppress warnings relative to incorrect static access( 抑制不正确的静态访问方式警告)
synthetic-access to suppress warnings relative to unoptimized access from inner classes( 抑制子类没有按最优方法访问内部类的警告)
unchecked to suppress warnings relative to unchecked operations( 抑制没有进行类型检查操作的警告)
unqualified-field-access to suppress warnings relative to field access unqualified( 抑制没有权限访问的域的警告)
unused to suppress warnings relative to unused code( 抑制没被使用过的代码的警告)

@SuppressWarnings 忽略警告

@SuppressWarnings 忽略警告

简介:java.lang.SuppressWarnings 是 J2SE 5.0 中标准的 Annotation 之一。可以标注在类、字段、方法、参数、构造方法,以及局部变量上。作用:告诉编译器忽略指定的警告,不用在编译完成后出现警告信息。
使用:
@SuppressWarnings(“”)
@SuppressWarnings({})
@SuppressWarnings(value={})

根据 sun 的官方文档描述:
value - 将由编译器在注释的元素中取消显示的警告集。允许使用重复的名称。忽略第二个和后面出现的名称。出现未被识别的警告名不是 错误:编译器必须忽略无法识别的所有警告名。但如果某个注释包含未被识别的警告名,那么编译器可以随意发出一个警告。

各编译器供应商应该将它们所支持的警告名连同注释类型一起记录。鼓励各供应商之间相互合作,确保在多个编译器中使用相同的名称。

示例:

·   @SuppressWarnings("unchecked")

  告诉编译器忽略 unchecked 警告信息,如使用 List,ArrayList 等未进行参数化产生的警告信息。

·   @SuppressWarnings("serial")

  如果编译器出现这样的警告信息:The serializable class WmailCalendar does not declare a static final serialVersionUID field of type long

 使用这个注释将警告信息去掉。

·   @SuppressWarnings("deprecation")

  如果使用了使用 @Deprecated 注释的方法,编译器将出现警告信息。
 使用这个注释将警告信息去掉。

·   @SuppressWarnings("unchecked", "deprecation")

  告诉编译器同时忽略 unchecked 和 deprecation 的警告信息。

·   @SuppressWarnings(value={"unchecked", "deprecation"})

  等同于 @SuppressWarnings ("unchecked", "deprecation")

1、抑制单类型警告

1 @SuppressWarnings("unchecked")
2 public void addItems(String item){
3   @SuppressWarnings("rawtypes")
4    List items = new ArrayList();
5    items.add(item);
6 }

2、抑制多类型警告

@SuppressWarnings(value={"unchecked", "rawtypes"})
public void addItems(String item){
   List items = new ArrayList();
   items.add(item);
}

3、抑制全部警告

1 @SuppressWarnings("all")
2 public void addItems(String item){
3    List items = new ArrayList();
4    items.add(item);
5 }

注解目标                                

 通过 @SuppressWarnings 的源码可知,其注解目标为类、字段、函数、函数入参、构造函数和函数的局部变量。而家建议注解应声明在最接近警告发生的位置。

抑制警告的关键字                                

 

关键字 用途
all to suppress all warnings
boxing  to suppress warnings relative to boxing/unboxing operations
cast to suppress warnings relative to cast operations
dep-ann to suppress warnings relative to deprecated annotation
deprecation to suppress warnings relative to deprecation
fallthrough  to suppress warnings relative to missing breaks in switch statements
finally  to suppress warnings relative to finally block that don’t return
hiding to suppress warnings relative to locals that hide variable
incomplete-switch  to suppress warnings relative to missing entries in a switch statement (enum case)
nls  to suppress warnings relative to non-nls string literals
null to suppress warnings relative to null analysis
rawtypes to suppress warnings relative to un-specific types when using generics on class params
restriction to suppress warnings relative to usage of discouraged or forbidden references
serial to suppress warnings relative to missing serialVersionUID field for a serializable class
static-access o suppress warnings relative to incorrect static access
synthetic-access   to suppress warnings relative to unoptimized access from inner classes
unchecked  to suppress warnings relative to unchecked operations
unqualified-field-access to suppress warnings relative to field access unqualified
unused to suppress warnings relative to unused code

@SuppressWarnings 注解

@SuppressWarnings 注解

简介:java.lang.SuppressWarnings 是 J2SE 5.0 中标准的 Annotation 之一。可以标注在类、字段、方法、参数、构造方法,以及局部变量上。
作用:告诉编译器忽略指定的警告,不用在编译完成后出现警告信息。
使用:
@SuppressWarnings(“”)
@SuppressWarnings({})
@SuppressWarnings(value={})

根据 sun 的官方文档描述:
value - 将由编译器在注释的元素中取消显示的警告集。允许使用重复的名称。忽略第二个和后面出现的名称。出现未被识别的警告名不是 错误:编译器必须忽略无法识别的所有警告名。但如果某个注释包含未被识别的警告名,那么编译器可以随意发出一个警告。

各编译器供应商应该将它们所支持的警告名连同注释类型一起记录。鼓励各供应商之间相互合作,确保在多个编译器中使用相同的名称。

示例:

·  @SuppressWarnings("unchecked")

告诉编译器忽略 unchecked 警告信息,如使用 List,ArrayList 等未进行参数化产生的警告信息。

·  @SuppressWarnings("serial")

如果编译器出现这样的警告信息:The serializable class WmailCalendar does not declare a static final serialVersionUID field of type long
     使用这个注释将警告信息去掉。

·  @SuppressWarnings("deprecation")

如果使用了使用 @Deprecated 注释的方法,编译器将出现警告信息。
     使用这个注释将警告信息去掉。

·  @SuppressWarnings("unchecked", "deprecation")

告诉编译器同时忽略 unchecked 和 deprecation 的警告信息。

·  @SuppressWarnings(value={"unchecked", "deprecation"})

等同于 @SuppressWarnings ("unchecked", "deprecation")

今天的关于JSP中是否有与java @SuppressWarnings等效的文件jsp如何与javabean结合?二者如何传递消息?的分享已经结束,谢谢您的关注,如果想了解更多关于@SuppressWarnings、@SuppressWarnings () java warning 警告、@SuppressWarnings 忽略警告、@SuppressWarnings 注解的相关知识,请在本站进行查询。

本文将带您了解关于iframe的备用文字的新内容,同时我们还将为您解释iframe的document的相关知识,另外,我们还将为您提供关于flex 嵌入 iframe 点iframe 外面的区域 iframe会消失 解决方法、Flex嵌套Iframe,点击除Iframe的其他地方后,Iframe内容消失的问题、Flex通过Iframe使用activex控件,点击除Iframe的其他地方后,Iframe内容消失、frame与iframe的区别的实用信息。

本文目录一览:

iframe的备用文字(iframe的document)

iframe的备用文字(iframe的document)

我们altimgHTML中的标记提供了替代文本,属性,该标记会在图像不显示时显示。我也尝试过使用标记iframe

<iframe src="www.abc.com" alt="Web site is not avaialable">

但是给出后,备用文本不会出现src=""。只是想知道我是否可以通过其他任何方式获得替代文本,如果src没有给出?

答案1

小编典典

由于我的第一次尝试曲解了您的问题,因此请尝试以下操作:

<script>$(function () {    $("iframe").not(":has([src])").each(function () {    var ifrm = this;    ifrm = (ifrm.contentWindow) ? ifrm.contentWindow : (ifrm.contentDocument.document) ? ifrm.contentDocument.document : ifrm.contentDocument;    ifrm.document.open();    ifrm.document.write($(this).attr("alt"));    ifrm.document.close();    });});</script>

这将读取任何不具有src属性或具有空白值的src属性的iframe的“ alt”标记值,并将alt文本写入该iframe的主体中。

flex 嵌入 iframe 点iframe 外面的区域 iframe会消失 解决方法

flex 嵌入 iframe 点iframe 外面的区域 iframe会消失 解决方法

flex 嵌入 iframe 点iframe 外面的区域 iframe会消失。。 解决办法

http://hi.baidu.com/qiyangyang2009/blog/item/ebc9731d72b2a98587d6b685.html

RIA知识库 
flex 
RIA 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> 
    <!-- 
    Smart developers always View Source. 
    
    This application was built using Adobe Flex,an open source framework
    for building rich Internet applications that get delivered via the
    Flash Player or to desktops via Adobe AIR. 
    
    Learn more about Flex at http://flex.org 
    // -->
    <head>
        <title></title>         
        <Meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   <!-- Include CSS to eliminate any default margins/padding and set the height of the html element and 
       the body element to 100%,because Firefox,or any Gecko based browser,interprets percentage as 
    the percentage of the height of its parent container,which has to be set explicitly. Initially, 
    don't display flashContent div so it won't show if JavaScript disabled.
   -->
        <style type="text/css" media="screen"> 
    html,body { height:100%; }
    body { margin:0; padding:0; overflow:auto; text-align:center; 
          background-color: #ffffff; }   
    #flashContent { display:none; }
        </style>
  
   <!-- Enable browser History by replacing usebrowserHistory tokens with two hyphens -->
        <!-- BEGIN browser History required section -->
        <link rel="stylesheet" type="text/css" href="history/history.css" />
        <script type="text/javascript" src="history/history.js"></script>
        <!-- END browser History required section --> 
      
        <script type="text/javascript" src="swfobject.js"></script>
        <script type="text/javascript">
            <!-- For version detection,set to min. required Flash Player version,or 0 (or 0.0.0),for no version detection. --> 
            var swfVersionStr = "10.0.0";
            <!-- To use express install,set to playerProductInstall.swf,otherwise the empty string. -->
            var xiSwfUrlStr = "playerProductInstall.swf";
            var flashvars = {};
            var params = {};

            / /在嵌入flex的html页面中加入这个,

           //object里有个   wmode的属性,你把他设为透明就行了。

            params.wmode="transparent";

 params.quality = "high";             params.bgcolor = "#ffffff";             params.allowscriptaccess = "sameDomain";             params.allowfullscreen = "true";             var attributes = {};             attributes.id = "timeline";             attributes.name = "timeline";             attributes.align = "middle";             swfobject.embedSWF(                 "timeline.swf","flashContent",                  "100%","100%",                  swfVersionStr,xiSwfUrlStr,                  flashvars,params,attributes);     <!-- JavaScript enabled so display the flashContent div in case it is not replaced with a swf object. -->     swfobject.createCSS("#flashContent","display:block;text-align:left;");         </script>     </head>     <body>         <!-- SWFObject's dynamic embed method replaces this alternative HTML content with Flash content when enough      JavaScript and Flash plug-in support is available. The div is initially hidden so that it doesn't show     when JavaScript is disabled.    -->         <div id="flashContent">         <p>          To view this page ensure that Adobe Flash Player version       10.0.0 or greater is installed.      </p>     <script type="text/javascript">       var pageHost = ((document.location.protocol == "https:") ? "https://" : "http://");       document.write("<a href='http://www.adobe.com/go/getflashplayer'><img src='"           + pageHost + "www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' /></a>" );      </script>          </div>             <noscript>             <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%" id="timeline">                 <param name="movie" value="timeline.swf" />                 <param name="quality" value="high" />                 <param name="bgcolor" value="#ffffff" />                 <param name="allowScriptAccess" value="sameDomain" />                 <param name="allowFullScreen" value="true" />                 <!--[if !IE]>-->                 <object type="application/x-shockwave-flash" data="timeline.swf" width="100%" height="100%">                     <param name="quality" value="high" />                     <param name="bgcolor" value="#ffffff" />                     <param name="allowScriptAccess" value="sameDomain" />                     <param name="allowFullScreen" value="true" />                 <!--<![endif]-->                 <!--[if gte IE 6]>-->                 <p>                     Either scripts and active content are not permitted to run or Adobe Flash Player version                    10.0.0 or greater is not installed.                 </p>                 <!--<![endif]-->                     <a href="http://www.adobe.com/go/getflashplayer">                         <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash Player" />                     </a>                 <!--[if !IE]>-->                 </object>                 <!--<![endif]-->             </object>      </noscript>      </body> </html>

Flex嵌套Iframe,点击除Iframe的其他地方后,Iframe内容消失的问题

Flex嵌套Iframe,点击除Iframe的其他地方后,Iframe内容消失的问题

原文地址: http://www.voidcn.com/article/p-kzlryzrd-bck.html

今天遇到一个很让人闹心的问题,就是我的Flex中为了嵌套一个jsp,所以在flex中嵌套一个包含JSP页面的Iframe。问题出现了,当我点击除了Iframe的其他地方的时候,Iframe中的内容全部消失了。刚开始我还困惑到底是怎么回事,后来才发现这个问题是完全可以解决的。解决的方法如下:

          在index.template.html中更改一个属性,index.template.html在你的flex工程下,目录为 :工程名\html-template\index.template.html。打开后,查看window的属性"wmode",看到后,将其值更改为"transparent"。一般一共会有三个地方。更改完后保存,重新编译,启动工程,成功!

         具体的代码如下:(注意红色字体)

<!-- saved from url=(0014)about:internet -->
<html lang="en">

<!--
Smart developers always View Source.

This application was built using Adobe Flex,an open source framework
for building rich Internet applications that get delivered via the
Flash Player or to desktops via Adobe AIR.

Learn more about Flex at http://flex.org
// -->

<head>
<Meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!--  BEGIN browser History required section -->
<link rel="stylesheet" type="text/css" href="history/history.css" />
<!--  END browser History required section -->

<title>${title}</title>
<script src="AC_OETags.js" language="javascript"></script>

<!--  BEGIN browser History required section -->
<script src="history/history.js" language="javascript"></script>
<!--  END browser History required section -->

<style>
body { margin: 0px; overflow:hidden }
</style>
<script language="JavaScript" type="text/javascript">
<!--
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = ${version_major};
// Minor version of Flash required
var requiredMinorVersion = ${version_minor};
// Minor version of Flash required
var requiredRevision = ${version_revision};
// -----------------------------------------------------------------------------
// -->
</script>
<script src="../scripts/hello.js" language="javascript"></script>
</head>

<body scroll="no">
<script language="JavaScript" type="text/javascript">
<!--
// Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
var hasProductInstall = DetectFlashVer(6,65);

// Version check based upon the values defined in globals
var hasRequestedVersion = DetectFlashVer(requiredMajorVersion,requiredMinorVersion,requiredRevision);

if ( hasProductInstall && !hasRequestedVersion ) {
 // DO NOT MODIFY THE FOLLOWING FOUR LInes
 // Location visited after installation is complete if installation is required
 var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
 var MMredirectURL = window.location;
    document.title = document.title.slice(0,47) + " - Flash Player Installation";
    var MMdoctitle = document.title;

 AC_FL_runcontent(
  "src","playerProductInstall",
  "FlashVars","MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
  "width","${width}",
  "height","${height}",
  "align","middle",
  "id","${application}",
  "quality","high",
  "bgcolor","${bgcolor}",
  "name",
  "allowScriptAccess","sameDomain",
  "type","application/x-shockwave-flash",
  "wmode","transparent", 
  "pluginspage","http://www.adobe.com/go/getflashplayer"
 );
} else if (hasRequestedVersion) {
 // if we've detected an acceptable version   transparent
 // embed the Flash Content SWF when all tests are passed
 AC_FL_runcontent(
   "src","${swf}",
   "width",
   "height",
   "align",
   "id",
   "quality",
   "bgcolor",
   "name",
   "allowScriptAccess",
   "type",
   "wmode", 
   "pluginspage","http://www.adobe.com/go/getflashplayer"
 );
  } else {  // flash is too old or we can't detect the plugin
    var alternateContent = 'Alternate HTML content should be placed here. '
   + 'This content requires the Adobe Flash Player. '
    + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
    document.write(alternateContent);  // insert non-flash content
  }
// -->
</script>
<noscript>
   <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
   id="${application}" width="${width}" height="${height}"
   codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
   <param name="movie" value="${swf}.swf" />
   <param name="quality" value="high" />
   <param name="bgcolor" value="${bgcolor}" />
   <param name="allowScriptAccess" value="sameDomain" />
   <embed src="${swf}.swf" quality="high" bgcolor="${bgcolor}"
    width="${width}" height="${height}" name="${application}" align="middle"
    play="true"
    loop="false"
    quality="high"
    allowScriptAccess="sameDomain"
    type="application/x-shockwave-flash"
    pluginspage="http://www.adobe.com/go/getflashplayer" wmode="transparent">
   </embed>
 </object>
</noscript>
</body>
</html>

 

二、flex里嵌套iframe,点击iframe,再点击外层的组件,iframe里的html内容变没了,不知道为什么?

这个问题其实很简单... 里面加wmode="transparent"就OK了. 跟你代码没有关系. 其实就swf与网页容器的上下层关系问题.当你点击的时候,swf跑到容器后面去了.所以看不见.其实他在网页上的.
1、<object>里面加<param name="wmode" value="transparent" /><embed>加wmode="transparent"就OK了.
2、 flex4修改方式如下:也是修改目录名:工程名\html-template\index.template.html文件
 
具体代码如下:(注意红色字体)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns=" http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> 
    <!--
    Smart developers always View Source.
   
    This application was built using Adobe Flex,an open source framework
    for building rich Internet applications that get delivered via the
    Flash Player or to desktops via Adobe AIR.
   
    Learn more about Flex at http://flex.org
    // -->
    <head>
        <title>${title}</title>        
        <Meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <!-- Include CSS to eliminate any default margins/padding and set the height of the html element and
       the body element to 100%,because Firefox,or any Gecko based browser,interprets percentage as
    the percentage of the height of its parent container,which has to be set explicitly.  Initially,
    don't display flashContent div so it won't show if JavaScript disabled.
  -->
        <style type="text/css" media="screen">
   html,body { height:100%; }
   body { margin:0; padding:0; overflow:auto; text-align:center;
          background-color: ${bgcolor}; }  
   #flashContent { display:none; }
        </style>
  
  <!-- Enable browser History by replacing usebrowserHistory tokens with two hyphens -->
        <!-- BEGIN browser History required section ${usebrowserHistory}>
        <link rel="stylesheet" type="text/css" href="history/history.css" />
        <script type="text/javascript" src="history/history.js"></script>
        <!${usebrowserHistory} END browser History required section --> 
     
        <script type="text/javascript" src="swfobject.js"></script>
        <script type="text/javascript">
            <!-- For version detection,set to min. required Flash Player version,or 0 (or 0.0.0),for no version detection. -->
            var swfVersionStr = "${version_major}.${version_minor}.${version_revision}";
            <!-- To use express install,set to playerProductInstall.swf,otherwise the empty string. -->
            var xiSwfUrlStr = "${expressInstallSwf}";
            var flashvars = {};
            var params = {};
            params.quality = "high";
            params.bgcolor = "${bgcolor}";
            params.allowscriptaccess = "sameDomain";
            params.allowfullscreen = "true";
            params.wmode = "transparent";   //添加部分
            var attributes = {};
            attributes.id = "${application}";
            attributes.name = "${application}";
            attributes.align = "middle";
            swfobject.embedSWF(
                "${swf}.swf","flashContent",
                "${width}",
                swfVersionStr,xiSwfUrlStr,
                flashvars,params,attributes);
   <!-- JavaScript enabled so display the flashContent div in case it is not replaced with a swf object. -->
   swfobject.createCSS("#flashContent","display:block;text-align:left;");
        </script>
    </head>
    <body>
        <!-- SWFObject's dynamic embed method replaces this alternative HTML content with Flash content when enough
    JavaScript and Flash plug-in support is available. The div is initially hidden so that it doesn't show
    when JavaScript is disabled.
  -->
        <div id="flashContent">
         <p>
          To view this page ensure that Adobe Flash Player version
    ${version_major}.${version_minor}.${version_revision} or greater is installed.
   </p>
   <script type="text/javascript">
    var pageHost = ((document.location.protocol == "https:") ? "https://" : "http://");
    document.write("<a href='http://www.adobe.com/go/getflashplayer'><img src='"
        + pageHost + " www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' /></a>" );
   </script>
        </div>
     
        <noscript>
            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="${width}" height="${height}" id="${application}">
                <param name="movie" value="${swf}.swf" />
                <param name="quality" value="high" />
                <param name="bgcolor" value="${bgcolor}" />
                <param name="allowScriptAccess" value="sameDomain" />
                <param name="allowFullScreen" value="true" />
                <param name="wmode" value="transparent" /><!--添加部分-->
                <!--[if !IE]>-->
                <object type="application/x-shockwave-flash" data="${swf}.swf" width="${width}" height="${height}">
                    <param name="quality" value="high" />
                    <param name="bgcolor" value="${bgcolor}" />
                    <param name="allowScriptAccess" value="sameDomain" />
                    <param name="allowFullScreen" value="true" />
                <!--<![endif]-->
                <!--[if gte IE 6]>-->
                 <p>
                  Either scripts and active content are not permitted to run or Adobe Flash Player version
                  ${version_major}.${version_minor}.${version_revision} or greater is not installed.
                 </p>
                <!--<![endif]-->
                    <a href=" http://www.adobe.com/go/getflashplayer">
                        <img src=" http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash Player" />                     </a>                 <!--[if !IE]>-->                 </object>                 <!--<![endif]-->             </object>      </noscript>      </body> </html>

Flex通过Iframe使用activex控件,点击除Iframe的其他地方后,Iframe内容消失

Flex通过Iframe使用activex控件,点击除Iframe的其他地方后,Iframe内容消失

解决办法如下(此办法是网上其他地方提出的,使用后果然可以解决以上问题):


 在index.template.html中更改一个属性,index.template.html在你的flex工程下,目录为 :工程名\html-template\index.template.html。打开后,查看window的属性"wmode",看到后,将其值更改为"transparent"。一般一共会有三个地方。更改完后保存,重新编译,启动工程,成功!

         具体的代码如下:(注意红色字体)

<!-- saved from url=(0014)about:internet -->
<html lang="en">

<!--
Smart developers always View Source.

This application was built using Adobe Flex,an open source framework
for building rich Internet applications that get delivered via the
Flash Player or to desktops via Adobe AIR.

Learn more about Flex at http://flex.org
// -->

<head>
<Meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!--  BEGIN browser History required section -->
<link rel="stylesheet" type="text/css" href="history/history.css" />
<!--  END browser History required section -->

<title>${title}</title>
<script src="AC_OETags.js" language="javascript"></script>

<!--  BEGIN browser History required section -->
<script src="history/history.js" language="javascript"></script>
<!--  END browser History required section -->

<style>
body { margin: 0px; overflow:hidden }
</style>
<script language="JavaScript" type="text/javascript">
<!--
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = ${version_major};
// Minor version of Flash required
var requiredMinorVersion = ${version_minor};
// Minor version of Flash required
var requiredRevision = ${version_revision};
// -----------------------------------------------------------------------------
// -->
</script>
<script src="../scripts/hello.js" language="javascript"></script>
</head>

<body scroll="no">
<script language="JavaScript" type="text/javascript">
<!--
// Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
var hasProductInstall = DetectFlashVer(6,65);

// Version check based upon the values defined in globals
var hasRequestedVersion = DetectFlashVer(requiredMajorVersion,requiredMinorVersion,requiredRevision);

if ( hasProductInstall && !hasRequestedVersion ) {
 // DO NOT MODIFY THE FOLLOWING FOUR LInes
 // Location visited after installation is complete if installation is required
 var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
 var MMredirectURL = window.location;
    document.title = document.title.slice(0,47) + " - Flash Player Installation";
    var MMdoctitle = document.title;

 AC_FL_runcontent(
  "src","playerProductInstall",
  "FlashVars","MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
  "width","${width}",
  "height","${height}",
  "align","middle",
  "id","${application}",
  "quality","high",
  "bgcolor","${bgcolor}",
  "name",
  "allowScriptAccess","sameDomain",
  "type","application/x-shockwave-flash",
  "wmode","transparent", 
  "pluginspage","http://www.adobe.com/go/getflashplayer"
 );
} else if (hasRequestedVersion) {
 // if we've detected an acceptable version   transparent
 // embed the Flash Content SWF when all tests are passed
 AC_FL_runcontent(
   "src","${swf}",
   "width",
   "height",
   "align",
   "id",
   "quality",
   "bgcolor",
   "name",
   "allowScriptAccess",
   "type",
   "wmode", 
   "pluginspage","http://www.adobe.com/go/getflashplayer"
 );
  } else {  // flash is too old or we can't detect the plugin
    var alternateContent = 'Alternate HTML content should be placed here. '
   + 'This content requires the Adobe Flash Player. '
    + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
    document.write(alternateContent);  // insert non-flash content
  }
// -->
</script>
<noscript>
   <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
   id="${application}" width="${width}" height="${height}"
   codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
   <param name="movie" value="${swf}.swf" />
   <param name="quality" value="high" />
   <param name="bgcolor" value="${bgcolor}" />
   <param name="allowScriptAccess" value="sameDomain" />
   <embed src="${swf}.swf" quality="high" bgcolor="${bgcolor}"
    width="${width}" height="${height}" name="${application}" align="middle"
    play="true"
    loop="false"
    quality="high"
    allowScriptAccess="sameDomain"
    type="application/x-shockwave-flash"
    pluginspage="http://www.adobe.com/go/getflashplayer" wmode="transparent">   </embed> </object></noscript></body></html>

frame与iframe的区别

frame与iframe的区别

1、frame不能脱离frameSet单独使用,iframe可以;

2、frame不能放在body中;如下可以正常显示:
<!--<body>-->
<frameset rows="50%,*">
   <frame   name="frame1"   src="test1.htm"/> 
   <frame   name="frame2"   src="test2.htm"/> 
</frameset>
<!--<body>-->

如下不能正常显示:
<body>
<frameset rows="50%,*">
   <frame   name="frame1"   src="test1.htm"/> 
   <frame   name="frame2"   src="test2.htm"/> 
</frameset>
<body>

3、嵌套在frameSet中的iframe必需放在body中;如下可以正常显示:
  <body>
    <frameset> 
      <iframe   name="frame1"   src="test1.htm"/> 
      <iframe   name="frame2"   src="test2.htm"/> 
    </frameset> 
  </body>
如下不能正常显示:

  <!--<body>-->
    <frameset> 
      <iframe   name="frame1"   src="test1.htm"/> 
      <iframe   name="frame2"   src="test2.htm"/> 
    </frameset> 
  <!--</body>-->


4、不嵌套在frameSet中的iframe可以随意使用;
     如下均可以正常显示:
<body>
   <iframe   name="frame1"   src="test1.htm"/> 
   <iframe   name="frame2"   src="test2.htm"/> 
</body>


<!--<body>-->
   <iframe   name="frame1"   src="test1.htm"/> 
   <iframe   name="frame2"   src="test2.htm"/> 
<!--</body>-->


5、frame的高度只能通过frameSet控制;iframe可以自己控制,不能通过frameSet控制,如:

<!--<body>-->
<frameset rows="50%,*">
   <frame   name="frame1"   src="test1.htm"/> 
   <frame   name="frame2"   src="test2.htm"/> 
</frameset>
<!--</body>-->

<body>
<frameset>
   <iframe height="30%"  name="frame1"   src="test1.htm"/> 
   <iframe height="100"  name="frame2"   src="test2.htm"/> 
</frameset>
</body>


6、如果在同一个页面使用了两个以上的iframe,在IE中可以正常显示,在firefox中只能显示出第一个;使用两个以上的frame在IE和firefox中均可正常

以上代码在IE7和firefox2.0中测试。

另外相关论坛窃取总结 :-)
1Frame与Iframe两者可以实现的功能基本相同,不过Iframe比Frame具有更多的灵活性。
frame是整个页面的框架,iframe是内嵌的网页元素,也可以说是内嵌的框架

Iframe标记又叫浮动帧标记,可以用它将一个HTML文档嵌入在一个HTML中显示。它和Frame标记的最大区别是在网页中嵌入的<Iframe></Iframe>所包含的内容与整个页面是一个整体,而<Frame></Frame>所包含的内容是一个独立的个体,是可以独立显示的。另外,应用Iframe还可以在同一个页面中多次显示同一内容,而不必重复这段内容的代码。

2iframe 可以放到表格里面。frame 则不行。
<table>
<tr>
<td><iframe id="" src=""></iframe></td><td></td>
</tr>
</table>

3frame必须在frameset里
而frameset不能与body元素共存,也就说有frameset元素的文档只能是一个框架集,不能有别的东东

4IFrame是放在网业的什么地方都行  
  但是frame只能放到上下左右四个方向

5iframme   是活动帧  
  而frame是非活动帧  
  iframe使用方法如下  
  <iframe   scr="sourcefile"   frameborder=0   width="width"   height="height"></iframe>
iframe用起来更灵活,不需要frame那么多讲究  
而且放的位置也可以自己设
iframe是内嵌的,比较灵活,不过也有不好的地方,就是位置在不同的浏览器和分辨率下有可能不同,有时会把本来好好的页面搞得变形

iframe就没有这个限制

6iframe   可以加在网页中任何一个地方。  
  而frame   通常做框架页
iframe是一个网页中的子框架,两网页间是父子关系  
   
  frame是框架,由多个并列的网页构成
楼上的说得对,iframe是浮动的。就像是浮动面板,而frame是固定的。只能四个方向上的。  
你可以直接在网页里用一下,看看效果就行了。


7<iframe>是被嵌入在网页的元素,而<frame>用于组成一个页面的多个框架!
iframe   更利于版面的设计  
  frame     一条直一条竖的不美观
frame的那一条线也可以去掉的呦!只不过,iframe更方便对其进行数据的交换吧!
iframe可以放置到你想放的任意位置,控制起来比frame方便

8iframe是内部帧,可以嵌在一个页面里面,设置内部帧的属性可以使得整体看上去象一个完整的页面,而不是由多个页面组成,frame有frame的好处,比如何多网站,上面放广告条,左边放菜单,右边放内容,这样上边和左边的内容都可不动,只刷新右边页面的内容,选择iframe还是frame完全看自己的需求。

说白了,用IFrame比用Frame少一个文件(FrameSet),但支持Frame的浏览器比较多。

我为我公司做的网站,整个是用了iframe,linux带的浏览器都不支持,哎呀,丑呀,不过我还是喜欢用iframe

还有iframe可以放在表格里,然后ifame设置成width=100%   height=100%  
  我就可以只需修改我的表格的宽度和高度,这样的话有利于排版 

其实Frame是一个控件  
  使用方法和Panle相同。

frame是把网页分成多个页面的页面。它要有一个框架集页面frameset  
  iframe是一个浮动的框架,就是在你的页面里再加上一个页面,

<frame>用来把页面横着或竖着切开,  
  <iframe>用来在页面中插入一个矩形的小窗口

Frame一般用来设置页面布局,将整个页面分成规则的几块,每一块里面包含一个新页面.  
  iframe用来在页面的任何地方插入一个新的页面.  
   
  因此,Frame用来控制页面格式,比如一本书,左边是章节目录,右边是正文,正文很长,看的时候要拖动,但又不想目录也被拖动得开不到了.因此最好将页面用Frame分成规则的2页,一左一右.  
   
  而iframe则更灵活,不要求将整个页面划分,你可以在页面任何地方用iframe嵌入新的页面.

我个人认为:  
  <frame>用于全页面  
  <iframe>只用于局部 

我们今天的关于iframe的备用文字iframe的document的分享已经告一段落,感谢您的关注,如果您想了解更多关于flex 嵌入 iframe 点iframe 外面的区域 iframe会消失 解决方法、Flex嵌套Iframe,点击除Iframe的其他地方后,Iframe内容消失的问题、Flex通过Iframe使用activex控件,点击除Iframe的其他地方后,Iframe内容消失、frame与iframe的区别的相关信息,请在本站查询。

关于是否可以在JSP中显示Swing组件?jsp swing的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于delphi – 是否可以在报表生成器报表中显示PDF?、delphi – 是否可以在设计时直观地设计自定义组件?、java – 正确更新swing组件?、javascript – 是否可以在ZingChart中显示印度系统中的值?等相关知识的信息别忘了在本站进行查找喔。

本文目录一览:

是否可以在JSP中显示Swing组件?(jsp swing)

是否可以在JSP中显示Swing组件?(jsp swing)

我想知道是否可以JOptionPane使用JSP在浏览器中弹出s或其他Swing组件。

答案1

小编典典

如果您嵌入小程序。但是我认为那不是您想要的。Swing适用于桌面应用程序。JSP网页。如果需要组件,请尝试研究JSF或许多AJAX
Javascript框架(例如原型)。

delphi – 是否可以在报表生成器报表中显示PDF?

delphi – 是否可以在报表生成器报表中显示PDF?

我们使用报告生成器生成有关使用Delphi 2010开发的软件的报告.我有很多显示图像的报告,但是:

是否可以像显示JPG一样在报表生成器报表中显示PDF?

我们的一位客户希望显示仅包含带有图像的单个页面的PDF(不要问我为什么不将其保存为JPG).但问题是,他有很多他不想转换的pdf.

解决方法

如果您将PDF转换为其他图像格式,则可能.

参考how to convert PDF to BMP/PNG/JPG etc etc

或者查看http://wiki.freepascal.org/PascalMagick

delphi – 是否可以在设计时直观地设计自定义组件?

delphi – 是否可以在设计时直观地设计自定义组件?

我正冒险在Delphi中制作自己的组件.我很难开始组件开发.

我想制作复合控件,即由几个其他控件组成的控件,例如地址表单或类似的控件.

我是从TWinControl下降的.这会被认为是正确的选择吗?

最重要的是,我看不到在D2010中可视化设计组件的方法.这可能吗?例如,将一些文本框放到组件上,就像使用表单一样.我希望我不必将所有视觉方面的代码都交给我自己的组件.

此外,delphi组件开发的任何好链接都将非常受欢迎 – 尤其是复合控件.文件不是A1,它是一场斗争.我已经搜索了很多,我仍然无处可去.

解决方法

如果您使用多个控件(例如地址表单)制作某些内容,则可以考虑将其设置为框架而不是控件.框架可以像窗户一样设计,并重复使用.

java – 正确更新swing组件?

java – 正确更新swing组件?

我是新手,任何帮助表示感谢.

在这段代码中,我正在翻牌,如果事实证明他们不匹配,我希望他们再次面朝下.

目前正在发生的事情:
1.点击时第一张卡翻过来
2.当点击第二张卡时,发生两件事情中的任何一件
(a)如果它们是相同的,它们都会熬夜,这就是我想要的
(b)如果它们不相同,我根本看不到第二张卡片,因为它立即重新显示卡片的背面(以及我的方法中定义的前一张卡片的背面).

我认为放入睡眠计时器可能会让第二张卡显示一段时间后再转回,但事实并非如此.

我试图使用contentPane.revalidate(); &安培; contentPane.repaint();但它没有改变任何东西.

我已经输入了一些控制台输出:

Console output:
Card: 0 set
Card: 6 set
Sleeping Now
Card: 6 unset
Card: 0 unset

上面是单击两张不匹配的卡时产生的控制台输出

@Override
public void actionPerformed(ActionEvent e) 
{
    String buttonpressed = e.getActionCommand();
    int pos = Integer.valueOf(buttonpressed);
    action = Control.model.ReceiveCardsTurned(pos);

    keypadArray[pos].setIcon(myIcons[pos]);     
    System.out.println("Card: "+pos+" set");
    currentTime.setText("" + Control.model.time);
    currentscore.setText("" + Control.model.score);

    //contentPane.revalidate();
    //contentPane.repaint();        

    if(Control.model.twoCardsTurned == false)
    {
        if (action == "unturn") 
        {
            System.out.println("Sleeping Now");

            try 
            {
                Thread.sleep(1000);
            }

            catch (InterruptedException e1) 
            {
                e1.printstacktrace();
            }

            keypadArray[pos].setIcon(back);
            keypadArray[Control.model.lastCard].setIcon(back);
            System.out.println("Card: "+pos+" unset");
            System.out.println("Card: "+Control.model.lastCard+" unset");
        }
    }
}

解决方法

您似乎缺少许多重要概念.

> Swing是一个事件驱动的环境.这意味着没有办法(或者至少只有极少数)你可以“等待”用户输入,通常,你只需要对他们的交互做出反应.
> Swing由单个线程驱动,称为事件调度线程(AKA EDT).此线程负责将进入应用程序的事件分派/处理到应用程序的相应部分,以便它们可以采取措施.
>重绘经理将其更新请求发布到EDT.

您采取的任何阻止EDT执行此工作的操作都会使您的应用程序看起来像是挂起的.

你不能在EDT上执行任何耗时的操作(例如I / O,循环或线程#sleep),这样做会使你的应用程序“暂停”,这从来都不是很好.

阅读Concurrency in Swing以获取更多信息.

现在,您有很多选择.您可以使用线程在后台“等待”并转回卡,或者您可以使用SwingWorker或javax.swing.Timer.

您遇到的另一个问题是,您不应该从EDT以外的任何线程更新任何UI组件.这意味着如果您使用Thread,您将负责将该线程与EDT重新同步.虽然不难,但它变得凌乱.

SwingWorker和javax.swing.Timer具有使这更容易的功能.

Threads和SwingWorker非常适合执行后台处理,并且对于这个问题只是过度杀伤.相反,javax.swing.Timer完全适合这里.

if (!Control.model.twoCardsTurned)
    {
        if ("unturn".equals(action)) 
        {
            new Timer(1000,new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    keypadArray[pos].setIcon(back);
                    keypadArray[Control.model.lastCard].setIcon(back);
                    System.out.println("Card: "+pos+" unset");
                    System.out.println("Card: "+Control.model.lastCard+" unset");
                }
            }).start();
        }
    }

这是一个非常简单的例子.您可能希望放置一些控件,以防止用户在计时器触发之前单击任何内容,例如;)

javascript – 是否可以在ZingChart中显示印度系统中的值?

javascript – 是否可以在ZingChart中显示印度系统中的值?

显示lakhs,crores中的值而不是数百万.

function formatIndianSuffix(num) {
    var x = parseInt(num).toString();
    var len = x.length;
    var formattednum = "";
    if (len <= 3) {
        formattednum = '₹' + Math.floor(x);
    } else if (len > 3 && len < 6) {
        formattednum = '₹' + (roundOff(x / 1000)).toString() + ' K'
    } else if (len >= 6 && len < 8) {
        formattednum = '₹' + (roundOff(x / 100000)).toString() + ' L'
    } else if (len >= 8) {
        formattednum = '₹' + (roundOff(x / 10000000)).toString() + ' Cr'
    }
    return formattednum;
}

我正在使用此函数格式化数字,但如何在图表中使用它?

最佳答案
完全披露,我是ZingChart团队的成员.

我们支持构建比例标签的功能.这是一个类似想法的工作示例.

var gFactor = 1.000;
var gFactorMultiplier = 1000;
var myConfig = {
 	type: "bar",scaleY:{
    "factor": gFactor,"format":"formatMyLabels()",label:{
 	    text:"Size"
 	  }
 	},plotarea:{
 	  margin: "dynamic"
 	},series : [
		{
			values : [899,1024,1142,2267,3389,4425,5534,6667,7785]
		}
	]
};

window.formatMyLabels = function(v) { 
  var localFactor = gFactor * gFactorMultiplier;
  switch(localFactor) {
    case 1000:
      if (v < 1000) {
        return v;
      } else if (v >= 1000 && v < 1000000) {
        return v/1000 + 'K'
      } else if (v >= 1000000) {
        return v/1000000 + 'M'
      }
      break;
    case 1024:
     if (v < 1024) { 
        return v + 'bps'; 
      } else if (v >= 1024) {
        return v/1024  + 'kbps'; 
      } 
      break;
  }
 
}

zingchart.render({ 
	id : 'myChart',data : myConfig,height: 400,width: '100%' 
});

关于是否可以在JSP中显示Swing组件?jsp swing的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于delphi – 是否可以在报表生成器报表中显示PDF?、delphi – 是否可以在设计时直观地设计自定义组件?、java – 正确更新swing组件?、javascript – 是否可以在ZingChart中显示印度系统中的值?的相关知识,请在本站寻找。

对于JSTL if标签是否包含相等的字符串感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍jstl标签if判断,并为您提供关于ios – 如何检查字符串是否包含空格/字母数字/等的字符?、java – 字符串包含相同的字符但仍然不同、js 判断字符串中是否包含某个字符串、js 判断字符串中是否包含某个字符串的方法实例的有用信息。

本文目录一览:

JSTL if标签是否包含相等的字符串(jstl标签if判断)

JSTL if标签是否包含相等的字符串(jstl标签if判断)

我的JSP页面上的一个对象有一个变量:

<%= ansokanInfo.getPSystem() %>

变量的值是NAT,它是正确的,我想对此值应用某些页面元素。如何使用标签来了解情况?我尝试了类似的东西

<c:if test = "${ansokanInfo.getPSystem() == ''NAT''}">         process  </c:if>

但是上面没有显示任何内容。我该怎么办?或者我也可以使用scriptlet

<% if (ansokanInfo.getPSystem().equals("NAT"){ %>process<% } %>

感谢您的任何回答或评论。

答案1

小编典典

尝试:

<c:if test = "${ansokanInfo.PSystem == ''NAT''}">

JSP / Servlet 2.4(我认为是版本号)不支持EL中的方法调用,而仅支持属性。最新的servlet容器确实支持方法调用(即Tomcat 7)。

ios – 如何检查字符串是否包含空格/字母数字/等的字符?

ios – 如何检查字符串是否包含空格/字母数字/等的字符?

如何使用 Swift中的“ctype.h”库可以在字符上使用isAlpha或isspace?还是有更好的,斯威夫特的方式呢?

这个问题得到回答,但似乎不起作用:
Swift: how to find out if letter is Alphanumeric or Digit

它没有指定如何导入库.有人可以指出我的方向正确吗?

这是我到目前为止

extension String {
    subscript (i : Int) -> String {
        return String(Array(self)[i])
    }
}

let whitespace = NSCharacterSet.whitespaceCharacterSet()

let phrase = "Test case"

for var i=0; i<countElements(phrase); i++ {
    if whitespace.characterIsMember(phrase[i]) { //error
        println("char is whitespace")
    }
}

解决方法

在整个字符串上使用NSCharacter,而不是逐个字符:
let whitespace = NSCharacterSet.whitespaceCharacterSet()

let phrase = "Test case"
let range = phrase.rangeOfCharacterFromSet(whitespace)

// range will be nil if no whitespace is found
if let test = range {
    println("whitespace found")
}
else {
    println("whitespace not found")
}

输出:

whitespace found

java – 字符串包含相同的字符但仍然不同

java – 字符串包含相同的字符但仍然不同

参见英文答案 > Two identical Strings are not equal(Not pointer/reference mistake)1个
我正在尝试读取.txt文件并使用每个句子作为团队的名称,同时使用该名称来寻找另一个.txt文件来获取其内容.所有.txt文件都位于我的assets文件夹的根目录下.第一个.txt文件工作正常,我使用assetmanager.open和readLine()来获取字符串,但是当使用该字符串作为参数来获取第二个.txt时,我得到一个java.io.FileNotFoundException.但是,当使用硬编码字符串调用相同的.txt文件时,一切正常.经过进一步检查,我发现硬编码字符串和用作参数的字符串在使用equals()函数后返回false.

这是调用first.txt的方法

private void loadTeams() {
    try {
        BufferedReader r = new BufferedReader(new InputStreamReader(assetManager.open("matches.txt")));
        String name,bio,trainer;
        for(int i = 0; i < 4; i++){
            name = r.readLine();
            bio = r.readLine();
            trainer = r.readLine();
            System.out.println(name+","+bio+","+trainer);
            teams[i] = new Team(name,i,loadplayers(name),trainer);
        }
        r.close();
    } catch (FileNotFoundException e) {
        e.printstacktrace();
    } catch (IOException e) {
        e.printstacktrace();
    }
}

使用“name”作为以下方法的参数:

private Player[] loadplayers(String teamName){
    Player[] players = new Player[11];

    try {
        String path = "team_Netherlands.txt";     //works
        String path2 = "team_"+teamName+".txt";     //doesn't work?
        System.out.println("are "+path+" and " +path2 +" the same? "+path.equals(path2));

        BufferedReader r = new BufferedReader(new InputStreamReader(assetManager.open(path2)));

        //perform operations on the obtained info
        r.close();
    } catch (FileNotFoundException e) {
        e.printstacktrace();
    } catch (IOException e) {
        e.printstacktrace();
    }

    return players;
}

文件中的第一句是“荷兰”(没有引号)
我认为应该导致team_Netherlands.txt为path2变量.
然而,使用它会使应用程序崩溃.使用路径变量它可以正常工作. println确认字符串不相等. (见logcat的第一句)

logcat的:

05-26 11:18:23.152 2960-2960/com.myname.testapp I/System.out: are team_Netherlands.txt and team_Netherlands.txt the same? false
05-26 11:18:23.152 2960-2960/com.myname.testapp W/System.err: java.io.FileNotFoundException: team_Netherlands.txt
05-26 11:18:23.152 2960-2960/com.myname.testapp W/System.err:     at android.content.res.AssetManager.openAsset(Native Method)
05-26 11:18:23.152 2960-2960/com.myname.testapp W/System.err:     at android.content.res.AssetManager.open(AssetManager.java:354)
05-26 11:18:23.152 2960-2960/com.myname.testapp W/System.err:     at android.content.res.AssetManager.open(AssetManager.java:328)
05-26 11:18:23.152 2960-2960/com.myname.testapp W/System.err:     at com.myname.testapp.Poule_Activity.load_Players(Poule_Activity.java:144)
05-26 11:18:23.152 2960-2960/com.myname.testapp W/System.err:     at com.myname.testapp.Poule_Activity.load_Teams(Poule_Activity.java:94)
05-26 11:18:23.152 2960-2960/com.myname.testapp W/System.err:     at com.myname.testapp.Poule_Activity.onCreate(Poule_Activity.java:53)
05-26 11:18:23.152 2960-2960/com.myname.testapp W/System.err:     at android.app.Activity.performCreate(Activity.java:5990)
05-26 11:18:23.152 2960-2960/com.myname.testapp W/System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
05-26 11:18:23.152 2960-2960/com.myname.testapp W/System.err:     at android.app.ActivityThread.performlaunchActivity(ActivityThread.java:2332)
05-26 11:18:23.152 2960-2960/com.myname.testapp W/System.err:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2442)
05-26 11:18:23.152 2960-2960/com.myname.testapp W/System.err:     at android.app.ActivityThread.access$800(ActivityThread.java:156)
05-26 11:18:23.152 2960-2960/com.myname.testapp W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1351)
05-26 11:18:23.152 2960-2960/com.myname.testapp W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
05-26 11:18:23.152 2960-2960/com.myname.testapp W/System.err:     at android.os.Looper.loop(Looper.java:211)
05-26 11:18:23.153 2960-2960/com.myname.testapp W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5373)
05-26 11:18:23.153 2960-2960/com.myname.testapp W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
05-26 11:18:23.153 2960-2960/com.myname.testapp W/System.err:     at java.lang.reflect.Method.invoke(Method.java:372)
05-26 11:18:23.153 2960-2960/com.myname.testapp W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020)
05-26 11:18:23.153 2960-2960/com.myname.testapp W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815)

为什么这些字符串不相等以及如何使它们相等? (即,使非硬编码字符串等于硬编码字符串)

解决方法

您从文件中读取的team_name包含前面的 UTF-8 byte order mark个八位字节
ef bb bf

并且它们在日志输出中不可见.

保存没有BOM的文件,或remove the BOM in your code.

js 判断字符串中是否包含某个字符串

js 判断字符串中是否包含某个字符串

String对象的方法

方法一: indexOf()   (推荐)

var str = "123";
console.log(str.indexOf("3") != -1 );  // true

indexOf() 方法可返回某个指定的字符串值在字符串中首次出现的位置。如果要检索的字符串值没有出现,则该方法返回 -1。

 

方法二: search() 

var str = "123";
console.log(str.search("3") != -1 );  // true

search() 方法用于检索字符串中指定的子字符串,或检索与正则表达式相匹配的子字符串。如果没有找到任何匹配的子串,则返回 -1。

 

方法三:match()

var str = "123";
var reg = RegExp(/3/);
if(str.match(reg)){
    // 包含        
}

match() 方法可在字符串内检索指定的值,或找到一个或多个正则表达式的匹配。

 

RegExp 对象方法

方法四:test() 

var str = "123";
var reg = RegExp(/3/);
console.log(reg.test(str)); // true

test() 方法用于检索字符串中指定的值。返回 true 或 false。

 

方法五:exec()

var str = "123";
var reg = RegExp(/3/);
if(reg.exec(str)){
    // 包含        
}

exec() 方法用于检索字符串中的正则表达式的匹配。返回一个数组,其中存放匹配的结果。如果未找到匹配,则返回值为 null。

js 判断字符串中是否包含某个字符串的方法实例

js 判断字符串中是否包含某个字符串的方法实例

String对象的方法

方法一: indexOf()   (推荐)

var str = "123";
console.log(str.indexOf("3") != -1 );  // true

indexOf() 方法可返回某个指定的字符串值在字符串中首次出现的位置。如果要检索的字符串值没有出现,则该方法返回 -1。

 

方法二: search() 

var str = "123";
console.log(str.search("3") != -1 );  // true

search() 方法用于检索字符串中指定的子字符串,或检索与正则表达式相匹配的子字符串。如果没有找到任何匹配的子串,则返回 -1。

 

方法三:match()

var str = "123";
var reg = RegExp(/3/);
if(str.match(reg)){
    // 包含        
}

match() 方法可在字符串内检索指定的值,或找到一个或多个正则表达式的匹配。

 

RegExp 对象方法

方法四:test() 

var str = "123";
var reg = RegExp(/3/);
console.log(reg.test(str)); // true

test() 方法用于检索字符串中指定的值。返回 true 或 false。

 

方法五:exec()

var str = "123";
var reg = RegExp(/3/);
if(reg.exec(str)){
    // 包含        
}

exec() 方法用于检索字符串中的正则表达式的匹配。返回一个数组,其中存放匹配的结果。如果未找到匹配,则返回值为 null。

我们今天的关于JSTL if标签是否包含相等的字符串jstl标签if判断的分享就到这里,谢谢您的阅读,如果想了解更多关于ios – 如何检查字符串是否包含空格/字母数字/等的字符?、java – 字符串包含相同的字符但仍然不同、js 判断字符串中是否包含某个字符串、js 判断字符串中是否包含某个字符串的方法实例的相关信息,可以在本站进行搜索。

如果您想了解使用URL访问Openshift中的数据目录open multiple urls的知识,那么本篇文章将是您的不二之选。我们将深入剖析使用URL访问Openshift中的数据目录的各个方面,并为您解答open multiple urls的疑在这篇文章中,我们将为您介绍使用URL访问Openshift中的数据目录的相关知识,同时也会详细的解释open multiple urls的运用方法,并给出实际的案例分析,希望能帮助到您!

本文目录一览:

使用URL访问Openshift中的数据目录(open multiple urls)

使用URL访问Openshift中的数据目录(open multiple urls)

我想在OpenShift中访问数据目录。我创建了一个文件夹,uploads并使用腻子创建了符号链接,但仍然无法访问该文件,它显示了404页。

当我最近开始使用OpenShift时,有人能详细告诉我该过程吗(逐步)。

另外,每当我使用git客户端更新存储库时,它都会删除符号链接。我正在做一个Maven项目。

答案1

小编典典

这是我遵循的步骤:

  1. cd <openshift deploy dir in my local system>
  2. touch .openshift/action_hooks/deploy
  3. vi .openshift/action_hooks/deploy
  4. 将以下代码粘贴ln -sf ${OPENSHIFT_DATA_DIR}images /var/lib/openshift/<app-id>/jbossews/webapps到文件中。注意:图像目录已经存在于openshift服务器的数据目录中。
  5. chmod +x .openshift/action_hooks/deploy
  6. git add .openshift/action_hooks/deploy
  7. git commit -a -m "added deploy"
  8. git push origin

我可以在此处访问图像文件夹:https:// app-url / images

希望这可以帮助

Cloudera 的数据管理平台将进入 OpenShift

Cloudera 的数据管理平台将进入 OpenShift

近日,Cloudera宣布计划在今年夏天在基于Kubernetes的Red Hat OpenShift上提供基于Hadoop的数据管理平台的实例。

Cloudera首席产品官Arun Murthy说,Cloudera数据平台(CDP)私有云是对Amazon Web Services(AWS)和Microsoft上已经可用的平台实例的补充。

Murthy强调,此举目标是使IT团队能够在云或本地IT环境中部署基于CDP的数据仓库,并在混合云计算环境中移动数据。

由于Kubernetes的兴起,现在在云计算环境之间移动工作负载变得更加容易。但是,在云平台之间移动数据存在更大的问题。Murthy指出,CDP简化了云平台之间的数据移动,使IT团队可以保留元数据以及应维护的相关安全和治理控制。

他说,这很关键,因为在COVID-19大流行带来的经济衰退之后,许多IT组织都希望集中管理多个云以降低总成本。

Murthy说,Cloudera将根据需求增加对Kubernetes其他发行版的支持,并指出Red Hat OpenShift当前是在本地IT环境中部署的Kubernetes的主要发行版。

CDP基于Hadoop的两个发行版,这些发行版是去年年初Cloudera-Hortonworks合并后的结果。从那时起,Hadoop和Kubernetes在推动结合了机器和深度学习算法的人工智能应用程序的开发中发挥了关键作用。Hadoop提供了一种管理大量数据的方法,而Kubernetes精心策划的容器使使用微服务来构建和部署原本笨拙的单块AI应用程序成为可能。

当然,随着要聚合的数据量达到PB,“大数据”一词已变得有些陈词滥调。问题不在于存储和处理的数据量,还在于确保在正确的时间向正确的微服务提供正确的数据。实际上,数据集需要作为可被多个微服务访问的逻辑实体进行管理。

实际上,Cloudera已经在CDP之上提供了单独的数据仓库,机器学习以及数据管理和分析服务,以简化特定用例范围内的数据管理。

在Kubernetes支持的混合云计算时代,IT团队可能需要一段时间才能掌握所有数据管理的细微差别。但是,随着组织试图从其收集的数据中获取更多价值,他们将需要更灵活的方法来管理大量数据。随着敏捷开发方法和DevOps的兴起,创建和部署应用程序从未如此简单。相比之下,在太多组织中,为那些应用程序提供对所需数据的访问权限仍然很积极。

消息来自:https://containerjournal.com/topics/container-management/clouderas-data-management-platform-comes-to-openshift

Docker – OpenShift V3与OpenShift V2

Docker – OpenShift V3与OpenShift V2

我正在寻找OpenShift V3和V2之间的主要区别.
OpenShift V2是这样工作的吗?:https://www.openshift.com/walkthrough/how-it-works
Docker和Kubernetes在V3中如何工作?

有人可以给我一个关于OpenShift V2和V3的建立的清晰解释

最佳答案
这是一个相当广泛的问题,所以我会(而且可以)只以相当广泛的方式回答.

有很多关键概念发生了变化.这些是最重要的,您需要一些时间才能进入,但它们对OpenShift v2有很大的改进:

>墨盒与Docker容器
> Gears vs. Kubernetes Pods
>经纪与库伯纳斯大师
>发布Red Hat Enterprise Linux Atomic
Host

当你学习下面的链接时,你会明白,OpenShift v3基本上与v2,除了名称,标识和PaaS的焦点基本上没有任何关系.但它仍然是一个伟大的工具,海事组织已经在PaaS世界中制定了新的标准. (不,我不为RedHat工作)

什么是新的:

https://docs.openshift.com/enterprise/3.0/whats_new/overview.html
https://docs.openshift.com/enterprise/3.0/architecture/overview.html

对于初学者; Docker& Kubernetes:

https://blog.openshift.com/openshift-v3-platform-combines-docker-kubernetes-atomic-and-more/

漂亮新:

Creating a Kubernetes Cluster to Run Docker Formatted Container Images

EDIT 2016_06_30:
对不起,坏死这个老帖子,但我想添加这个快速,有趣和非常翔实的视频关于Kubernetes:https://youtu.be/4ht22ReBjno

javascript中的push(),unshift(),pop(),shift()方法

javascript中的push(),unshift(),pop(),shift()方法

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>

<p id="demo"></p>
	<p id="result"></p>
<button onclick="myFunction()">push</button><!--在数组的尾部添加元素并返回新长度-->
	<button onclick="myFunction1()">unshift</button><!--在数组的开头添加元素并返回新的长度-->
	<button onclick="myFunction2()">pop</button><!--从数组的尾部删除元素返回值为删除的元素-->
	<button onclick="myFunction3()">shift</button><!--从数组的开头删除元素返回值为删除的元素-->
<script>
var fruits = ["Banana", "Orange", "Apple", "Mango"];
	var x=document.getElementById("demo");
	x.innerHTML=fruits;
function myFunction(){
	var e = fruits.push("Kiwi");
	var p = document.getElementById("result");
	p.innerHTML=e;
	var x=document.getElementById("demo");
	x.innerHTML=fruits;
}
function myFunction1(){
	var e = fruits.unshift("Kiwi");
	var p = document.getElementById("result");
	p.innerHTML=e;
	var x=document.getElementById("demo");
	x.innerHTML=fruits;
}
function myFunction2(){
	var e = fruits.pop("Kiwi");
	var p = document.getElementById("result");
	p.innerHTML=e;
	var x=document.getElementById("demo");
	x.innerHTML=fruits;
}
function myFunction3(){
	var e = fruits.shift("Kiwi");
	var p = document.getElementById("result");
	p.innerHTML=e;
	var x=document.getElementById("demo");
	x.innerHTML=fruits;
}
	
</script>

</body>
</html>

 

jenkins openshift 中的 Docker

jenkins openshift 中的 Docker

如何解决jenkins openshift 中的 Docker?


在 jenkins 管道中使用 docker 时出现问题:“docker: command not found”
如何在 OpenShift Jenkins 上启动 docker? 此外,没有权限在 Jenkins 中打开插件页面。

解决方法

在 OpenShift 上使用 Jenkins,您不会在 Jenkins 主服务器上找到任何 Docker 运行时 - 可能也不会在从服务器上找到:cri-o 是首选的运行时(并且只有运行时,从 4.x 开始)。>

如果您想启动容器,您应该使用任何 OpenShift 或 Kubernetes 插件:创建 Pod。在 OpenShift 中,除了编写管道之外,您不需要在 Jenkins 本身上配置或安装任何东西。只要您的 Jenkins ServiceAccount 对 Project 具有编辑或管理权限,那么它就可以管理相应 Namespace 中的容器。

Thread.activeCount()

如果您没有对 Jenkins 管理界面的完全访问权限,请检查该命名空间中的 RoleBindings:也许您不是管理员?

它不会阻止您创建自己的 podTemplates(使用 ConfigMaps)、Credentials(使用 Secrets)或 jobs/jenkinsFiles(使用 BuildConfigs)。虽然您可以向 Jenkins 安装其他插件,但可以在 Jenkins 部署中添加/更改 pipeline { agent { node { label ''maven'' } } stages { stage(''clone'') { // clone the repository serving your YAMLs } stage(''create'') { steps { script { openshift.withCluster() { openshift.withProject() { try { timeout(5) { objectsFromTemplate = openshift.process("-f","/path/to/clone/directory/deploy.yaml",''-p'',"FRONTNAME=${params.buildHash}","LDAP_IMAGE_TAG=${params.buildHash}","ROOT_DOMAIN=${params.rootDomain}") echo "The template will create ${objectsFromTemplate.size()} objects" for (o in objectsFromTemplate) { o.metadata.labels["${templateSel}"] = "${templateMark}-${params.buildHash}" } created = openshift.create(objectsFromTemplate) created.withEach { echo "Created ${it.name()} from template with labels ${it.object().metadata.labels}" } } } catch(e) { // DoSomething } } } } } } } } 环境变量的内容。

另请注意,Jenkins ServiceAccount 令牌可用于以管理员身份对 Jenkins 进行身份验证,解决 Jenkins OpenShift OAuth 集成问题。

,

最简单的方法是使用 OpenShift 提供的 jenkins 安装

OpenShift 中 jenkins 的文档在这里:https://docs.openshift.com/container-platform/4.8/openshift_images/using_images/images-other-jenkins.html

要构建 docker 镜像,建议的解决方案是使用“源到镜像”(s2i) 和/或使用"BuildConfig"来管理“docker builds”

该文档还解释了如何使用与 OCP 集成的 jenkins(OAuth + 角色绑定到 OpenShift)来管理 jenkins 身份验证/授权

加分项:jenkins 配置了所有需要的插件(k8s、OCP...),并且在升级 OCP 时会自动升级

我们今天的关于使用URL访问Openshift中的数据目录open multiple urls的分享已经告一段落,感谢您的关注,如果您想了解更多关于Cloudera 的数据管理平台将进入 OpenShift、Docker – OpenShift V3与OpenShift V2、javascript中的push(),unshift(),pop(),shift()方法、jenkins openshift 中的 Docker的相关信息,请在本站查询。

在本文中,我们将为您详细介绍如何在Struts2中具有两个条件的if的相关知识,并且为您解答关于struts2 s:if的疑问,此外,我们还会提供一些关于06. struts2中指定struts2处理的请求后缀、amcharts在struts2中的应用、i18n在Struts2中使用拦截器、java – 如何在struts2中仅获取响应中的特定字段的有用信息。

本文目录一览:

如何在Struts2中具有两个条件的if(struts2 s:if)

如何在Struts2中具有两个条件的if(struts2 s:if)

我遍历项目列表,如果元素的状态等于学生或老师,则需要显示特定的下拉列表。以下代码显示了所有字段,但未显示任何元素的下拉列表!

 <s:iterator value="listOfPeople" status="element">   .....  <s:if test=''%{elements[#element.index].Status.equalsIgnoreCase("Student") ||          elements[#element.index].Status.equalsIgnoreCase("Teacher")}''>            <s:select name="elements[%{#element.index}].Status"                               id="elements[%{#element.index}].Status"                               label="Status"                               list="#{''Student'':''Student'',''Teacher'':''Teacher''}"                               headerKey = "-1"                               headerValue=" "                               value="%{Status}"             />    </s:if>

在控制器中:

    PeopleModel peopleModel = new PeopleModel();    listOfPeople = peopleModel.findPeople();    System.out.println("size is:" + listOfPeople.size());  //returns 8    return "listPeople";

我的模特:

    List<People> people = new ArrayList();    final Session session = HibernateUtil.getSession();    try {        final Transaction tx = session.beginTransaction();        try {            Criteria criteria = session.createCriteria(People.class, "People")            people.addAll((List<People>) criteria.list());            if (!tx.wasCommitted()) {                tx.commit();            }            if (session.isOpen()) {                session.close();            }            System.out.println("size is ::: " + people.size());   //returns 8            return people;        } catch (Exception e) {            tx.rollback();            e.printStackTrace();        }    } finally {        HibernateUtil.closeSession();    }    return null;}

以下代码的结果是自爆

   Status: ${Status}   <br/>value : [<s:property value="elements[%{#element.index}].Status" />]Status : Principlevalue : [] Status : Studentvalue : [] Status : Teachervalue : [] Status : Teachervalue : [] Status : Teachervalue : [] Status : Teachervalue : [] Status : Teachervalue : [] Status : Teachervalue : []

以上结果显示了第一个人的状态与其他人的状态分离,这就是为什么最后一个值[]没有显示任何状态的原因。

如果我取出状态:$ {Status},结果将是

value : []value : []value : []value : []value : []value : []value : []value : []

答案1

小编典典

放在%{}整个表达式周围,而不是放在其他标记的其他属性中间:

还要对字符串使用更合适的相等函数

<s:if test=''%{elements[#element.index].status.equalsIgnoreCase("Student") ||              elements[#element.index].status.equalsIgnoreCase("Teacher")}''>

编辑 :伙计,你在做很多奇怪的事情;

  1. ${Status} 是JSP EL,您无需使用它;
  2. 您正在迭代一个源,然后检查另一个源:打印<s:property value="elements[%{#element.index}].Status" />会给您带来空洞的结果,而我elements在代码中的任何地方都看不到该东西。
  3. 在属性中的第一个大写字母是WRONG,因为如果变量被命名foo并且getter是getFoo(),则在页面中您将拥有.foo,而不是.Foo。如果您的变量名为Foo,则违反规范/最佳做法,让我们以小写字母开头的变量名称。

然后,如果有private Object Status,将其private Objectstatus;与getter和setter一起更改为,并在页面中使用:

<s:iterator value="listOfPeople" status="element">    <s:if test=''%{listOfPeople[#element.index].status.equalsIgnoreCase("Student") ||                  listOfPeople[#element.index].status.equalsIgnoreCase("Teacher")}''>

或使用var

<s:iterator value="listOfPeople" status="element" var="row">    <s:if test=''%{row.status.equalsIgnoreCase("Student") ||                  row.status.equalsIgnoreCase("Teacher")}''>

或简单地

<s:iterator value="listOfPeople" status="element">    <s:if test=''%{status.equalsIgnoreCase("Student") ||                  status.equalsIgnoreCase("Teacher")}''>

奇怪的代码导致奇怪的结果…然后直接使用它:)

06. struts2中指定struts2处理的请求后缀

06. struts2中指定struts2处理的请求后缀

概述

  • 默认情况下我们都是使用.action后缀访问Action。
  • 其实默认后缀是可以通过常量”struts.action.extension“进行修改的。
  • 我们可以配置Struts 2只处理以.do为后缀的请求路径

    • <struts>  
          <constant name="struts.action.extension" value="do"/>  
      </struts>  
  • 如果用户需要指定多个请求后缀,则多个后缀之间以英文逗号(,)隔开。如:

    • <constant name="struts.action.extension" value="do,go"/>
  • 一些常用的常量

    • <!-- 指定默认编码集,作用于HttpServletRequest的setCharacterEncoding方法 和freemarker 、velocity的输出 -->  
      <constant name="struts.i18n.encoding" value="UTF-8"/>  
      
      <!-- 该属性指定需要Struts 2处理的请求后缀,该属性的默认值是action,即所有匹配*.action的请求都由Struts2处理。
           如果用户需要指定多个请求后缀,则多个后缀之间以英文逗号(,)隔开。 -->  
      <constant name="struts.action.extension" value="do"/>  
        
      <!-- 设置浏览器是否缓存静态内容,默认值为true(生产环境下使用),开发阶段最好关闭 -->  
      <constant name="struts.serve.static.browserCache" value="false"/>  
        
      <!-- 当struts的配置文件修改后,系统是否自动重新加载该文件,默认值为false(生产环境下使用),开发阶段最好打开 -->  
      <constant name="struts.configuration.xml.reload" value="true"/>  
        
      <!-- 开发模式下使用,这样可以打印出更详细的错误信息 -->  
      <constant name="struts.devMode" value="true" />  
        
      <!-- 默认的视图主题 -->  
      <constant name="struts.ui.theme" value="simple" />  
        
      <!– 与spring集成时,指定由spring负责action对象的创建 -->  
      <constant name="struts.objectFactory" value="spring" />  
        
      <!–该属性设置Struts 2是否支持动态方法调用,该属性的默认值是true。如果需要关闭动态方法调用,则可设置该属性为false。 -->  
      <constant name="struts.enable.DynamicMethodInvocation" value="false"/>  
        
      <!--上传文件的大小限制-->  
      <constant name="struts.multipart.maxSize" value=“10701096"/>  

常量定义位置

  • 常量可以在struts.xml或struts.properties中配置,建议在struts.xml中配置
  • 两种配置方式如下:

    • 在struts.xml文件中配置常量
    • <struts>  
          <constant name="struts.action.extension" value="do"/>  
      </struts>  
    • 在struts.properties中配置常量

      struts.action.extension=do
  • 也可在多个配置文件中进行定义

struts2加载常量的搜索顺序

  • struts-default.xml
  • struts-plugin.xml
  • struts.xml
  • struts.properties
  • web.xml
如果在多个文件中配置了同一个常量,则后一个文件中配置的常量值会覆盖前面文件中配置的常量值.

amcharts在struts2中的应用

amcharts在struts2中的应用

查看选中的软件的下载量,通过amchart报表工具显示出软件日下载量,月下载量以及年下载量,下面简单介绍,amchart在struts2中的应用。

amCharts提供JavaScript/HTML5图表。一套包括串行(列,栏,线,区,步线,平滑线,烛台,OHLC图),馅饼/甜甜圈,雷达/极性和XY /分散/气泡图。amCharts的图表提供了无与伦比的功能和性能,在一个高级的,符合标准的包里。

一、下载amchart

        点击进入下载页面

        选择你想使用的报表显示形状进行下载,较常用的主要是曲线图和饼图,这里以曲线图为例:Line & Area

 

二、配置struts2

        新建一个Web Project,比如:amchartDemo

        1. JAR包引用

        这里使用的是struts2的最新JAR包:struts-2.2.1.1:

        该版本的struts2需要用到的JAR包有7个,一个都不能少

        可在下面工程中获取:struts-2.2.1.1\apps\struts2-blank\WEB-INF\lib

        commons-fileupload-1.2.1.jar

        commons-io-1.3.2.jar

        freemarker-2.3.16.jar

        javassist-3.7.ga.jar

        ognl-3.0.jar

        struts2-core-2.2.1.1.jar

        xwork-core-2.2.1.1.jar

 

        2. 配置web.xml (WebRoot\WEB-INF\web.xml)

Java代码   收藏代码
  1. <filter>  
  2.     <filter-name>struts2</filter-name>  
  3.     <filter-class>  
  4.         org.apache.struts2.dispatcher.FilterDispatcher  
  5.     </filter-class>  
  6. </filter>  
  7. <filter-mapping>  
  8.     <filter-name>struts2</filter-name>  
  9.     <url-pattern>/*</url-pattern>  
  10. </filter-mapping>  

 

        3. 配置struts.xml

            可从 struts-2.2.1.1\apps\struts2-blank\WEB-INF\src\java\ 获取struts.xml,复制到你自己的项目工程(amchartDemo)的src下 

 

Java代码   收藏代码
  1. <struts>  
  2.     <package name="statistic" extends="struts-default">  
  3.         <action name="report" class="com.web.action.ReportAction">  
  4.             <result name="show-suc">/index.jsp</result>  
  5.         </action>  
  6.     </package>  
  7. </struts>  

 

        4. 编写Action

            根据以上struts.xml的配置,创建ReportAction类,以及需要的Bean:

 

Java代码   收藏代码
  1. package com.web.action;  
  2.   
  3. import java.util.ArrayList;  
  4. import java.util.List;  
  5. import java.util.Map;  
  6. import java.util.TreeMap;  
  7.   
  8. import com.model.beans.BaseBean;  
  9. import com.opensymphony.xwork2.ActionContext;  
  10. import com.opensymphony.xwork2.ActionSupport;  
  11.   
  12. public class ReportAction extends ActionSupport {  
  13.   
  14.     public String showDay() throws Exception {  
  15.         List<BaseBean> daylist = new ArrayList<BaseBean>();  
  16.         /*================数据模拟==================*/  
  17.         daylist.add(createBean(1L,"软件A","#FF0000"));  
  18.         daylist.add(createBean(2L,"软件B","#FFC0CB"));  
  19.         daylist.add(createBean(3L,"软件C","#40E0D0"));  
  20.         daylist.add(createBean(4L,"软件D","#9ACD32"));  
  21.         daylist.add(createBean(5L,"软件E","#00FF7F"));  
  22.         /*=========================================*/  
  23.         ActionContext.getContext().getSession().put("chartDataList", daylist);  
  24.         return "show-suc";  
  25.     }  
  26.   
  27.     /** 
  28.      * 创建模拟数据 
  29.      * @author Christy Lan 
  30.      * @version 1.0 
  31.      * @param  
  32.      * @return BaseBean 
  33.      * @exception 
  34.      */  
  35.     private BaseBean createBean(Long id, String softName, String color){  
  36.         BaseBean bean = new BaseBean();  
  37.         bean.setSoftId(id);  
  38.         bean.setSoftName(softName);  
  39.         bean.setColor(color);  
  40.         Map<Integer, Integer> dataMap = new TreeMap<Integer, Integer>();  
  41.         //一天24小时  
  42.         for(int i = 1; i <= 24; i++){  
  43.             dataMap.put(i, getRandom());//模拟每小时的下载量  
  44.         }  
  45.         bean.setDataMap(dataMap);  
  46.         return bean;  
  47.           
  48.     }  
  49.       
  50.     private Integer getRandom(){  
  51.         return (int)(Math.random()*1000);  
  52.     }  
  53. }  
        该bean与数据库的表结构无关,而是对数据库中的数据进行了进一步的统计处理(使用oracle的统计函数),封装成这个BaseBean。主要就是对dataMap<时刻, 下载量>的封装
Java代码   收藏代码
  1. package com.model.beans;  
  2.   
  3. import java.util.Map;  
  4.   
  5. public class BaseBean {  
  6.       
  7.     private Long softId;//软件ID  
  8.     private String softName;//软件名字  
  9.     private String color;//该软件在amchart报表中显示的颜色  
  10.     private Map<Integer, Integer> dataMap;//存放统计信息  
  11.       
  12.     public Long getSoftId() {  
  13.         return softId;  
  14.     }  
  15.     public void setSoftId(Long softId) {  
  16.         this.softId = softId;  
  17.     }  
  18.     public String getSoftName() {  
  19.         return softName;  
  20.     }  
  21.     public void setSoftName(String softName) {  
  22.         this.softName = softName;  
  23.     }  
  24.     public String getColor() {  
  25.         return color;  
  26.     }  
  27.     public void setColor(String color) {  
  28.         this.color = color;  
  29.     }  
  30.     public Map<Integer, Integer> getDataMap() {  
  31.         return dataMap;  
  32.     }  
  33.     public void setDataMap(Map<Integer, Integer> dataMap) {  
  34.         this.dataMap = dataMap;  
  35.     }  
  36. }  
  

 

三、使用amchart

       1. 在WebRoot下新建一个目录 WebRoot/statistic/line

 

       2. 解压amline_1.6.4.1.zip

           a) 将 amline_1.6.4.1\amline 目录下的swfobject.js复制到statistic目录下(注:swfobject.js放于哪无所谓,关键是页面上的引用

           b) 将 amline_1.6.4.1\amline 目录下的amline.swf 复制到statistic/line目录下

           c) 将 amline_1.6.4.1\amline 目录下的amline_settings.xml 复制到statistic/line目录下,同时,把amline_settings.xml改名为day_settings.jsp

 

        3. 修改day_settings.jsp

           a) 在day_settings.jsp的最开始处增加如下代码:

 

Java代码   收藏代码
  1. <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>  
  2. <%@ taglib prefix="s" uri="/struts-tags" %>  

           b) 将<digits_after_decimal>2</digits_after_decimal> 改为

                  <digits_after_decimal>0</digits_after_decimal> 

                  这里的数值表示小数点后的位数

 

           c) 将<graphs></graphs>标签里的内容删除,替换成:

 

Java代码   收藏代码
  1. <graphs>                                                      
  2.   <s:iterator value="#session.chartDataList" status="st">  
  3.   <graph gid="<s:property value="#st.index"/>">  
  4.     <title><s:property value="softName"/></title>  
  5.     <line_width>2</line_width>  
  6.         <color><s:property value="color"/></color>  
  7.         <color_hover><s:property value="color"/></color_hover>  
  8.         <bullet>round_outlined</bullet>  
  9.         <balloon_text_color>000000</balloon_text_color>     
  10.         <balloon_text>  
  11.         <![CDATA[{title} on {series}: 【{value}次】]]>  
  12.         </balloon_text>  
  13.         <selected>true</selected>  
  14.   </graph>  
  15.   </s:iterator>  
  16. </graphs>   

        4. 在statistic/line目录下新建day_data.jsp

 

Java代码   收藏代码
  1. <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>  
  2. <%@ taglib prefix="s" uri="/struts-tags" %>  
  3. <?xml version="1.0" encoding="UTF-8"?>     
  4. <chart>  
  5.     <series>  
  6.         <s:iterator value="#session.chartDataList" status="st">  
  7.         <s:if test="#st.index==0">  
  8.             <s:iterator value="dataMap">  
  9.                 <value xid="<s:property value="key"/>"><s:property value="key"/>时</value>  
  10.             </s:iterator>  
  11.         </s:if>  
  12.         </s:iterator>  
  13.     </series>  
  14.     <graphs>  
  15.         <s:iterator value="#session.chartDataList" status="st">  
  16.         <graph gid="<s:property value="#st.index"/>">  
  17.             <s:iterator value="dataMap">  
  18.                 <value xid="<s:property value="key"/>"><s:property value="value"/></value>  
  19.             </s:iterator>  
  20.         </graph>  
  21.         </s:iterator>  
  22.     </graphs>  
  23. </chart>  

        5. 补充:破解amchart

             在statistic/line目录下新建amcharts_key.txt,内容为

 

             AMCHART-LNKS-1966-6679-1965-1082


        6. WebRoot/index.jsp
            1) 引入JS
Java代码   收藏代码
  1. <script type="text/javascript" src="<%=basePath %>/statistic/swfobject.js"></script>  
            2) amchart使用
Java代码   收藏代码
  1.  <body>  
  2.    <div id="flashcontent">  
  3.     <strong>You need to upgrade your Flash Player</strong>  
  4. </div>  
  5.   
  6. <script type="text/javascript">  
  7.     // <![CDATA[       
  8.     var so = new SWFObject("statistic/line/amline.swf""amline""900""600""8""#FFFFFF");  
  9.     so.addVariable("path""statistic/line/");  
  10.     so.addVariable("settings_file", encodeURIComponent("statistic/line/day_settings.jsp?<%=Math.random()%>"));  
  11.     so.addVariable("data_file", encodeURIComponent("statistic/line/day_data.jsp"));  
  12.     so.write("flashcontent");  
  13.     // ]]>  
  14. </script>  
  15.  </body>  
四、完成
       访问  http://localhost/amchartDemo/report!showDay.action  即可看到效果

i18n在Struts2中使用拦截器

i18n在Struts2中使用拦截器

我想使一个网站多语言。

我有一个普通的拦截器堆栈,其中包含

<interceptor-ref name="i18n" />

更改语言环境的通用jsp:

<s:a action="locale-manager" namespace="/common">    <s:param name="request_locale">fa_IR</s:param>    فارسی  </s:a><s:a action="locale-manager" namespace="/common">    <s:param name="request_locale">en_US</s:param>    English</s:a>

还有一个简单的LocaleManager动作

public class LocaleManager extends ActionSupport{    private static final Logger log = LoggerFactory.getLogger(LocaleManager.class);    public String execute() {        log.debug("Change the local to {}", getLocale() );        return "homepage";    }}

在上述情况下,i18n拦截器始终针对所有操作运行,但无法解决。因为仅当用户单击区域设置管理器操作时,区域设置才会更改。

我试图删除拦截器堆栈并将i18n拦截器仅添加到LocaleManager,如下所示

@InterceptorRefs({ @InterceptorRef("i18n") })public class LocaleManager extends ActionSupport{  .........

但是它没有用?!我是否缺少某些东西,还是应该编写自己的拦截器?

答案1

小编典典

始终I18nInterceptor为每个Action
运行拦截器…它是defaultStack(在 struts-
default.xml中

配置的)一部分,它存在是有原因的。

它以一种简单的方式工作:如果有一个名为的请求参数request_locale,它将新的语言环境设置为会话。然后,在调用getText()或类似函数从本地化包中获取正确的消息时,将读取该值。

从官方文档中:

拦截器,用于将会话中指定的语言环境设置为当前操作请求的语言环境。此外,此拦截器还将查找特定的HTTP请求参数,并将语言环境设置为提供的任何值。这意味着该拦截器可用于允许您的应用程序动态更改用户会话的语言环境,或者仅更改当前请求的语言环境(自XWork
2.1.3起)。这对于需要多语言支持并希望用户能够随时设置其语言首选项的应用程序非常有用。在执行此拦截器期间,将删除locale参数,以确保未在操作中没有典型对应设置程序的操作(例如request_locale)上设置属性。

例如,使用默认参数名称,对 foo.action?request_locale = en_US 的请求
,然后将美国英语的语言环境保存在用户的会话中,并将用于以后的所有请求。

如果没有设置语言环境(例如第一次访问),则拦截器将使用浏览器语言环境。

一些用法示例:

  • Struts 2 – i18n或本地化示例
  • struts2中的本地化(i18n)
  • Struts 2 I18N(Struts 2国际化)

java – 如何在struts2中仅获取响应中的特定字段

java – 如何在struts2中仅获取响应中的特定字段

我有一个动作类,其中定义了许多动作方法,并且还定义了适当的getter和setter方法.我有一些动作方法,我通过从jQuery调用它们来获取数据作为json.但是当我得到json数据时,它包含了定义了getter和setter的所有字段,但是我想只获得由我调用的那个方法填充的那个字段.例如-

public class ApplicantRegistration extends ActionSupport{
private String s1;
private XyzBean bean;
private String s2;
// respective getters and setters....

public String m1(){
// some work
 return SUCCESS;
}

public String m2(){
   //some work
    s2="abc";
    return SUCCESS;
}


}

当我通过jQuery调用方法m2并得到json响应时

{
 s1: null,
 bean: null,
 s2:"abc",
 m2: "success",

}

但我只想要

{
 s2:"abc"
}

解决方法:

默认情况下,json结果序列化root参数指定的所有bean属性,该参数默认设置为action.但是,您可以使用结果的includeProperties参数来仅过滤匹配正则表达式的根中的那些属性.

@Result(type="json", params = {"includeProperties", "^s2"})

今天关于如何在Struts2中具有两个条件的ifstruts2 s:if的分享就到这里,希望大家有所收获,若想了解更多关于06. struts2中指定struts2处理的请求后缀、amcharts在struts2中的应用、i18n在Struts2中使用拦截器、java – 如何在struts2中仅获取响应中的特定字段等相关知识,可以在本站进行查询。

如果您想了解如何在twitter-bootstrap模态窗口中插入Django表单?的相关知识,那么本文是一篇不可错过的文章,我们将对twitter bootstrap进行全面详尽的解释,并且为您提供关于ajax – Twitter Bootstrap模式表单提交、css – 在twitter-bootstrap中居中模态、jquery – Twitter Bootstrap模态表单提交、jquery – 在Bootstrap模式中提交Django表单的有价值的信息。

本文目录一览:

如何在twitter-bootstrap模态窗口中插入Django表单?(twitter bootstrap)

如何在twitter-bootstrap模态窗口中插入Django表单?(twitter bootstrap)

有人在四月份提出了完全相同的问题,没有任何答案。但是由于他提供的信息太少了;这个问题被放弃了。

我也有同样的问题。在main_page.html我有这行:

<a href="/contact/edit/{{ item.id }}" title="Edit">edit</a>

一旦你单击此处,编辑模板将出现在Twitter引导程序模式内。

url.py

(r''^contact/edit/(?P<contact_id>\d+)/$'', contact_view),

view.py

def contact_view(request, contact_id=None):    profile = request.user.get_profile()    if contact_id is None:        contact = Contact(company=profile.company)        template_title = _(u''Add Contact'')    else:        contact = get_object_or_404(profile.company.contact_set.all(), pk=contact_id)        template_title = _(u''Edit Contact'')    if request.POST:        if request.POST.get(''cancel'', None):            return HttpResponseRedirect(''/'')        form = ContactsForm(profile.company, request.POST, instance=contact)        if form.is_valid():            contact = form.save()            return HttpResponseRedirect(''/'')    else:        form = ContactsForm(instance=contact, company=profile.company)    variables = RequestContext(request, {''form'':form, ''template_title'': template_title})    return render_to_response("contact.html", variables)

通常这是contact.html的外观:

        <formmethod="post" action=".">            {% csrf_token %}            {{form.as_p}}            <inputtype="submit" value="Save" />            <input name="cancel"type="submit" value="Cancel"/>        </form>

我可以把它放进去

。但是,如何从视图中打开模态?


阅读 265
收藏
2020-03-27

答案1

小编典典

除非你需要使用模态之外的联系表格,否则这应该对你有用。如果确实需要在其他地方使用它,请维护两个版本(一个模式,一个不使用)。另外,一个技巧-给django-crispy-forms一个过渡-它可以帮助你使用twitter-bootstrap类呈现表单。

contact.html:

<divid="contactModal"><formmethod="post" action="/contact/edit/{{ item.id }}">  <div>    <button type="button"data-dismiss="modal">×</button>    <h3>Editing Contact</h3>  </div>  <div>       {% csrf_token %}       {{form.as_p}}  </div>  <div>       <inputtype="submit" value="Save" />       <input name="cancel"type="submit" value="Cancel"/>  </div></form></div>

main_page.html

<html>...<a data-toggle="modal" href="#contactModal">Edit Contact</a>{% include "contact.html" %}...</html>

编辑:

好的,现在我知道你可能有多个表单,将每个表单都隐藏在html中可能是个坏主意。你可能想要使用ajax-y版本,并按需加载每种表单。我在这里假设在表单提交时,整个页面都会重新加载。如果你要异步提交表单,请在其他地方找到答案。

我们将从重新定义contact.html片段开始。它应该在模态中进行渲染,并包含与模态完美搭配所需的所有标记。contact你最初拥有的视图很好-除非表单无效,contact.html否则最终将呈现,而没有其他显示。

<formmethod="post" action="/contact/edit/{{ item.id }}">  <div>    <button type="button"data-dismiss="modal">×</button>    <h3>Editing Contact</h3>  </div>  <div>       {% csrf_token %}       {{form.as_p}} <!-- {{form|crispy}} if you use django-crispy-forms -->  </div>  <div>       <inputtype="submit" value="Save" />       <input name="cancel"type="submit" value="Cancel"/>  </div></form>

现在,你的main_page.html

<html>.. snip ..<ahref="#" data-form="/contact/edit/{{ item.id }}" title="Edit">edit</a><ahref="#" data-form="/contact/edit/{{ item.id }}" title="Edit">edit</a><ahref="#" data-form="/contact/edit/{{ item.id }}" title="Edit">edit</a><divid="contactModal"></div><script>    $(".contact").click(function(ev) { // for each edit contact url        ev.preventDefault(); // prevent navigation        var url = $(this).data("form"); // get the contact form url        $("#contactModal").load(url, function() { // load the url into the modal            $(this).modal(''show''); // display the modal on url load        });        return false; // prevent the click propagation    });    $(''.contact-form'').live(''submit'', function() {        $.ajax({             type: $(this).attr(''method''),             url: this.action,             data: $(this).serialize(),            context: this,            success: function(data, status) {                $(''#contactModal'').html(data);            }        });        return false;    });</script>.. snip ..</html>

这都是未经测试的,但它应该为你提供一个良好的起点/起点。

ajax – Twitter Bootstrap模式表单提交

ajax – Twitter Bootstrap模式表单提交

我是Twitter Bootstrap的初学者,我正在尝试从一个模式框处理一个表单,它也加载了Ajax.问题是我不知道如何使用它.我在谷歌搜索了几个小时,但我找不到一个很好的例子.

我之前使用过jquery ui,我想它可能几乎一样.
我想知道以下内容:

>如何加载包含Ajax表单的文件
>在加载表单之后简单地使用选择器(例如$(‘#item’);)是否有效,以获取在表单中键入的值
>如何绑定模式的“提交”按钮以通过Ajax将表单发送到另一个文件

我将非常感谢您的帮助,我可以提供以下表格样本:

<div>
    <button type="button"data-dismiss="modal" aria-hidden="true">&times;</button>
    <h3>Submit a link</h3>
    </div>
    <div>
    <div id="msgholder1"></div>
    <div id="msg-loader"></div>
    <form action="../ajax/controller.PHP" data-async data-target="#msgholder1" id="add-link-form" method="POST">
    <table id="theform">
    <tr>
    <td>URL:</td>
    <td><input type="text" name="url" size="45"id="url" /></td>
    </tr>
    <tr>
    <td>Quality:</td>
    <td><select name="quality" id="quality">
          <option value="0">Pick One ...</option>
          <option value="1">CAM</option>
          <option value="2">TS</option>
          <option value="3">DVD</option>
    </select><br />
    </td>
    </tr>
    <tr>
    </fieldset>
    </form>
    </div>
    <div>
    <buttondata-dismiss="modal" aria-hidden="true">Close</button>
    <button>Save changes</button>
    </div>

任何类型的相关文档也很有用.

谢谢!

解决方法

经过几个小时的研究和解决,我得到了以下工作Ajax Modal脚本:

<script type="text/javascript">
$(document).ready(function() {
  $('#addlink').on('click',function(event) {
    var href = SITEURL + '/modules/movies/addlink.tpl.PHP?movie_id=<?PHP echo $movie->id; ?>';
    $.get(href,function(response) {
      $('.modal').html(response);
      $('.modal').modal({keyboard:true});
      $('button#submit_link').bind('click',function()
        {
        $('.modal-body').html('<p>Loading ...</p>');
        $.ajax({
                    type: 'post',url: SITEURL + "/ajax/controller.PHP",data: 'action=report_link',dataType : 'html',context: $(this),success: function (msg) {
                        $(".modal-body").html(msg);
                    }
                });
        });
    });
    event.preventDefault();
  });
});
</script>

css – 在twitter-bootstrap中居中模态

css – 在twitter-bootstrap中居中模态

我无法将我的模态集中在各种大小的twitter-bootstrap中.您可以看到实时示例 here和 here.(只需单击图片或“报告此图像”).你会看到模态就像魅力一样,但它不是水平居中的.我尝试了一切:边距,浮动,文本对齐甚至< center>

.modal:

.modal {
      position: fixed;
      top: 10%;
      z-index: 1050;
      width: auto;
      background-color: #ffffff;
      border: 1px solid #999;
      border: 1px solid rgba(0,0.3);
      *border: 1px solid #999;
      -webkit-border-radius: 6px;
         -moz-border-radius: 6px;
              border-radius: 6px;
      outline: none;
      -webkit-Box-shadow: 0 3px 7px rgba(0,0.3);
         -moz-Box-shadow: 0 3px 7px rgba(0,0.3);
              Box-shadow: 0 3px 7px rgba(0,0.3);
      -webkit-background-clip: padding-Box;
         -moz-background-clip: padding-Box;
              background-clip: padding-Box;
    }

.modal体:

.modal-body {
 margin: 0 auto 0 auto;
  position: relative;
  padding: 15px;
  overflow-y: auto;
}

解决方法

我知道这有点晚了,但我找到了解决所有问题的方法,将Bootstrap Modal置于不同于标准(一个)的高度.

$("#yourModal").modal('show').css({
    'margin-top': function () { //vertical centering
        return -($(this).height() / 2);
    },'margin-left': function () { //Horizontal centering
        return -($(this).width() / 2);
    }
});

jquery – Twitter Bootstrap模态表单提交

jquery – Twitter Bootstrap模态表单提交

我最近一直在使用 java / jboss进行叽叽.witter boot been.,and and and and……………………….

这种形式在模态本身是外在的,我根本无法弄明白这是怎么可能的

我已经尝试将模态本身添加到窗体中,尝试使用HTML5 form =“form_list”,甚至将窗体添加到模态体,并使用一些jquery强制提交,但没有任何显示工作

下面是一个示例模式,我试图增加我需要的,OK按钮以前编辑尝试调用jquery函数.

<divid='myModal' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>
        <div>
            <button type='button'data-dismiss='modal' aria-hidden='true'>×</button>
            <h3 id='myModalLabel'>Delete Confirmation</h3>
        </div>
        <div>
            <p>Are you sure you want to delete the user?</p>
        </div>");
        <div>
        <buttondata-dismiss='modal' aria-hidden='true'>Cancel</button>
        <buttondata-dismiss='modal'>Ok</button>
        </div>
    </div>

解决方法

提交后要关闭模式吗?在窗体内部的模态或外部,你应该能够使用jQuery ajax来提交表单.

这里是一个模式中的形式的例子:

<a href="#myModal" role="button"data-toggle="modal">Launch demo modal</a>

<div id="myModal"tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div>
        <button type="button"data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="myModalLabel">Modal header</h3>
    </div>
    <div>
        <form id="myForm" method="post">
          <input type="hidden" value="hello" id="myField">
            <button id="myFormSubmit" type="submit">Submit</button>
        </form>
    </div>
    <div>
        <buttondata-dismiss="modal" aria-hidden="true">Close</button>
        <button>Save changes</button>
    </div>
</div>

和jquery ajax获取表单域并提交..

$('#myFormSubmit').click(function(e){
      e.preventDefault();
      alert($('#myField').val());
      /*
      $.post('http://path/to/post',$('#myForm').serialize(),function(data,status,xhr){
           // do something here with response;
         });
      */
});

工作在Bootply:http://bootply.com/59864

jquery – 在Bootstrap模式中提交Django表单

jquery – 在Bootstrap模式中提交Django表单

嘿家伙我是Django的新手,我正在试图弄清楚如何在模态中提交表单.我有两个有问题的Django应用程序,前端和登录.前端应用程序提供页面,登录应该处理表单.我使用crispy表单来呈现表单但无法提交表单.几天来一直在努力奋斗.阅读了很多关于此的帖子,仍然无法弄明白.任何帮助将不胜感激.非常感谢.我正在使用Django 1.6版

前端应用程序的urls.py:

from django.conf.urls import patterns,url
from django.contrib import admin
from frontend import views
from login.views import registration

urlpatterns = patterns('',url(r'^$',views.index,name='index'),url(r'^about/$',views.about,name='about'),url(r'^contact/$',views.contact,name='contact'),'index',views.registration,name='register'),)

前端应用程序的views.py:

from django.template import RequestContext
from django.shortcuts import render_to_response
from login.forms import RegistrationForm
from login.forms import LoginForm
from login.views import registration

def index(request):
    return render_to_response('index.html',{'regform':RegistrationForm(),'loginform': LoginForm()} )


def about(request):
    return render_to_response('about.html')

def contact(request):
    return render_to_response('contact.html')

登录应用的urls.py:

from django.conf.urls import patterns,url
from login import views

urlpatterns = patterns('',url(r'^register/$',name='index.html')

)

登录app的views.py:

from django.template import RequestContext
from django.shortcuts import render_to_response
from login.forms import RegistrationForm



def registration(request):


    context = RequestContext(request)


    registered = False


if request.method == 'POST':

    user_form = RegistrationForm(request.POST)



    user = user_form.save()


    user.set_password(user.password)
    user.save()

    registered = True




else:
    user_form = RegistrationForm()

return render_to_response('index.html',{'regform': user_form},context)

def login(request):
   context = RequestContext(request)
   login_form = LoginForm()
   return render_to_response('index.html',{loginform: login_form},context)

登录应用程序的forms.py:

from django.contrib.auth.models import User
from django import forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit,Layout,Field
from crispy_forms.bootstrap import (PrependedText,PrependedAppendedText,FormActions)
from login.models import User



class RegistrationForm(forms.ModelForm):
     password = forms.CharField(widget=forms.Passwordinput())

     class Meta:
           model = User
           fields = ('username','email','first_name','last_name','password')
           helper = FormHelper()
           helper.form_method = 'POST'
           helper.add_input(Submit('save','save',css_))

     class LoginForm(forms.ModelForm):
           password = forms.CharField(widget=forms.Passwordinput())

 class Meta:
    model = User
    fields = ('username','password')
@property   
def helper(self):        
    helper = FormHelper()
        helper.form_method = 'POST'
        helper.add_input(Submit('save',css_))
    return helper

Index.html模态:

<divid="myModal" tabindex="-1" role="dialog"  aria-labelledby="myModalLabel" aria-hidden="true">
  <div>
    <div>
      <div>
        <button type="button"data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4id="myModalLabel">Register </h4>
      </div>
      <div>
   <ul>
     <li><a href="#tab1" data-toggle="tab">Login</a></li>
         <li><a href="#tab2" data-toggle="tab">Register</a></li>
     </ul>
        <form action="" method=post"> 
         <div>
           <divid="tab1">

    {% crispy loginform %}

           </div>
           <divid="tab2">

    {% crispy regform %}

           </div>
         </form>
         </div>
      </div>
      <div>
        <button type="button"data-dismiss="modal">Cancel</button>
        <button type="button">Submit</button>

      </div>
    </div>
  </div>
</div>

使用Ajax尝试的模态(剪辑):

<div>
        <button type="button"data-dismiss="modal">Cancel</button>
        <button id="register" type="button">Submit</button>
        <script>
    $('#register').click(function(){
             console.log('am i called');

        $.ajax({
            type: "POST",url: "/register/",dataType: "json",data: $("#login").serialize(),success: function(data) {
            alert(data.message);
        }
    });

});
    </script>

Ajax请求的登录视图:

def addUser(request):
if request.is_ajax() and request.POST:
    data = {request.POST.get('item')}
    return HttpResponse(json.dumps(data),content_type='application/json') 
else:
raise Http404

正如请求的模式渲染HTML:

<!-- Modal --> 
<divid="myModal" tabindex="-1" role="dialog"   aria-labelledby="myModalLabel" aria-hidden="true">
  <div>
    <div>
      <div>
        <button type="button"data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4id="myModalLabel">Register </h4>
      </div>
      <div>
   <ul>
     <li><a href="#tab1" data-toggle="tab">Login</a></li>
         <li><a href="#tab2" data-toggle="tab">Register</a></li>
     </ul>
        <form id="login" action="/frontend/register/" method="POST"> 
         <div>
           <divid="tab1">

                用户名*必填. 30个字符或更少.字母,数字和@ / ./ / – / _字符
                密码*

</div>


           <divid="tab2">

                 用户名*必填. 30个字符或更少.字母,数字和@ / ./ / – / _字符
                电子邮件地址
             
                名字
               
                姓
               
                密码*

</div>
         </form>
         </div>
      </div>
    <div> 
        <button type="button"data-dismiss="modal">Cancel</button>
        <button id="register" type="button">Submit</button>
        <script>
    $('#register').click(function(){
             console.log('am i called');

        $.ajax({
            type: "POST",data: $(regform).serialize(),success: function(data) {
                if (!(data['success'])) {

                    $(example_form).replaceWith(data['form_html']);
            }
            else {

               $(example_form).find('.success-message').show();
            }
            },error: function () {
            $(example_form).find('.error-message').show()
            }
             }
            });

            });
    </script>


     </div> 
    </div>
  </div>
</div>

更新Ajax:

<script>
$(document).ready(function() {
var frm = $('#id-registration');
 frm.submit(function (e) {


    $.ajax({
        type: frm.attr('method'),<!-- Get the form's method attribute(defined in login/forms.py -->
        url: frm.attr('action'),<!-- Get the form's action attribute(defined in login/forms.py -->
        data: $(frm).serialize(),<!-- package the data -->
        success: function (data) {        <!-- if success return message -->
           if (!(data['success'])) {
            console.log('ifcalled')
            $(frm).replaceWith(data['form_html']); <!-- send replacement form with errors -->
           }
           else{
             console.log('elseCalled')
             $("#div-form").html("Thanks!");
            // $(frm).find('.success-message').show();
            }
        },error: function(data) {           <!-- else print error -->
            $(frm).find('.error-message').show()
        }
    });
  e.preventDefault(); <!-- problem is here,validation is all ways false -->

});

});
</script>

更新:
表单现在正在提交给数据库.但是表单验证不起作用. if / else控件似乎总是验证false.如果我删除form.submit().它起作用并显示表单错误,但页面刷新.

更新了views.py:

def addUser(request):

form = RegistrationForm(data=request.POST or None)
if form.is_valid():
    # You Could actually save through AJAX and return a success code here
    form.save()
    return {'success': True}

form_html = render_crispy_form(form)
return {'success': False,'form_html': form_html}

更新了Forms.py:

class RegistrationForm(forms.ModelForm):
    password = forms.CharField(widget=forms.Passwordinput())
    class Meta:
         model = User
         fields = ('username','password')
    def __init__(self,*args,**kwargs):
             super(RegistrationForm,self).__init__(*args,**kwargs)
             self.helper = FormHelper()
             self.helper.form_id = 'id-registration'
             self.helper.form_self.helper.form_method = 'post'
             self.helper.form_action = '/register/'
             self.helper.add_input(Submit('submit','Submit'))

这个问题已经解决:

<script type="text/javascript"     src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script type="text/javascript" src="{% static 'js/jquery-validation- 1.11.1/jquery.validate.js' %}"></script>   
<script>
$(document).ready(function () {
  var frm = $('#id-registration');
  $('#id-registration').validate({

    rules: {
        username: {required: true},email: {required: true},password: {required: true}

},submitHandler: function(){
    $.ajax({//begin
        type: 'POST',<!-- Get the form's action attribute(defined in   login/forms.py -->
        data: $(frm).serialize(),<!-- package the data -->
        success: function(data){
            $(frm).hide();
    $("#div-form").html("<h3>Thank you,for Registering!</h3>");

        },error: function(data) {           <!-- else print error -->
            $("#div-form").html("Failure!");
        }//end error
    });//end ajax

    return false;
    }   
    });   
    });



    </script>

解决方法

首先,我将启动您的浏览器开发人员工具(例如Firefox中的Firebug).如果发送了POST请求,请在“网络”选项卡中密切监视.

发送请求后,您可以检查请求的内容和答案.这有助于确定您的表单是否捕获了输入中的所有数据,或者您是否可能在使用urls.py时遇到问题.

如果表单正确提交(状态200),您可以开始调试Django App.

关于如何在twitter-bootstrap模态窗口中插入Django表单?twitter bootstrap的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于ajax – Twitter Bootstrap模式表单提交、css – 在twitter-bootstrap中居中模态、jquery – Twitter Bootstrap模态表单提交、jquery – 在Bootstrap模式中提交Django表单的相关知识,请在本站寻找。

本篇文章给大家谈谈如何在Struts 2中使用if标记?,以及struts2 if标签的知识点,同时本文还将给你拓展i18n在Struts2中使用拦截器、java – 在Struts 2中使用Ajax URL调用一个动作、java – 在Struts 2和Struts中使用cookies、java – 如何在struts2中仅获取响应中的特定字段等相关知识,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

如何在Struts 2中使用if标记?(struts2 if标签)

如何在Struts 2中使用if标记?(struts2 if标签)

我真的是Struts2的新手。我有下面的Struts2标记,我需要检查属性value="#attr.row.Commentaire是否不为空,如果不是,则显示一个小图标,用户可以在其中单击它并查阅属性的内容value="#attr.row.Commentaire。如何if有效地使用Struts2
的标签来做到这一点?

<display:column title="Commentaire" sortable="true" sortProperty="Commentaire">              <s:property value="#attr.row.Commentaire"/>

答案1

小编典典

使用以下代码

<s:if test="#attr.row.Commentaire != null && #attr.row.Commentaire != ''''">

if标签使用test属性来评估OGNL表达为布尔值。

您可能还需要使用一个a标签这使得可能与一起使用相结合的HTML锚标记if标签

咨询财产的内容

还有一个debug标签可用于包装其他标签,以向您显示将呈现调试数据的链接。

<s:debug>   <s:property value="%{#attr.row.Commentaire}"/></s:debug>

i18n在Struts2中使用拦截器

i18n在Struts2中使用拦截器

我想使一个网站多语言。

我有一个普通的拦截器堆栈,其中包含

<interceptor-ref name="i18n" />

更改语言环境的通用jsp:

<s:a action="locale-manager" namespace="/common">
    <s:param name="request_locale">fa_IR</s:param>
    فارسی  
</s:a>

<s:a action="locale-manager" namespace="/common">
    <s:param name="request_locale">en_US</s:param>
    English
</s:a>

还有一个简单的LocaleManager动作

public class LocaleManager extends ActionSupport{
    private static final Logger log = LoggerFactory.getLogger(LocaleManager.class);

    public String execute() {
        log.debug("Change the local to {}",getLocale() );
        return "homepage";
    }

}

在上述情况下,i18n拦截器始终针对所有操作运行,但无法解决。因为仅当用户单击区域设置管理器操作时,区域设置才会更改。

我试图删除拦截器堆栈并将i18n拦截器仅添加到LocaleManager,如下所示

@InterceptorRefs({ @InterceptorRef("i18n") })
public class LocaleManager extends ActionSupport{
  .........

但是它没有用?!我是否缺少某些东西,还是应该编写自己的拦截器?

java – 在Struts 2中使用Ajax URL调用一个动作

java – 在Struts 2中使用Ajax URL调用一个动作

我正在尝试使用Ajax中的URL连接到我的操作类.但它没有进入我的动作类,甚至没有使用$(“#selectedCountry”).val()显示所选值.
function getstates(){           
    alert($("#selectedCountry").val());         
    $.ajax({
      type : "GET",url  : "/ThirdTask/selectstate.action",dataType : 'text',data : "name="+$("#selectedCountry").val(),success : function(){
        $('statesdivid').html();
      },error : alert("No values found..!!")
    });         
}

我的JSP代码如下:

<s:select  name="selectedCountry"  list="{'india','china'}"  onclick="getstates();"/></div>
<div id="statesdivid">
<s:if test="%{#request.selectedstatenames != null}"> 
<s:select list="#request.selectedstatenames" name="selectedState">
</s:select>
</s:if>
</div>

我的struts.xml:

<action name="selectstate.action"method="selectstate">
 <result name="success">selecttag.jsp</result> 
</action>

解决方法

要将操作映射到方法,您应该执行类似的操作
<action name="selectstate"method="selectstate">
  <result>/selecttag.jsp</result> 
</action>

动作名称应该没有动作扩展名,默认情况下结果名为“success”,JSP的路径应该是绝对的.

打电话给ajax

$.ajax({
    type : "GET",url  : "<s:url action='selectstate'/>",dataType : 'text/javascript',data : {'name' : $("#selectedCountry").text()},success : function(result){
      if (result != null && result.length > 0){
        $("statesdivid").html(result);
      }
    },error : function(xhr,errmsg) {alert("No values found..!!");}
});

java – 在Struts 2和Struts中使用cookies

java – 在Struts 2和Struts中使用cookies

我有以下(缩短)struts2动作:
public class MyAction extends BaseAction implements CookiesAware {

  public String execute() {

    if (cookiesMap.containsKey("BLAH"))
      blah=Integer.parseInt(cookiesMap.get("BLAH"));

      return "success";
  }

  // For handling cookies
  Map<String,String> cookiesMap;
  @Override
  public void setCookiesMap(Map<String,String> cookiesMap) {
    this.cookiesMap = cookiesMap;
  }
}

当我做’cookieMap.containsKey’时,我得到一个空指针异常 – 在我看来,setCookiesMap没有被调用.我已经实现了CookiesAware接口,所以我会认为它应该被调用 – 我错过了这里的东西?

谢谢

解决方法

看起来struts只支持读取cookie,你必须去servlet响应来实际设置一个cookie.

最后,我已经选择完全绕过struts2 cookie支持,直接转到servlet请求/响应对象进行阅读和写入:

public class MyAction extends ActionSupport implements ServletResponseAware,ServletRequestAware {

  public int division;

  public String execute() {

    // Load from cookie
    for(Cookie c : servletRequest.getCookies()) {
      if (c.getName().equals("cookieDivision"))
        division=Integer.parseInt(c.getValue());
    }

    // Save to cookie
    Cookie div = new Cookie("cookieDivision",String.format("%d",division));
    div.setMaxAge(60*60*24*365); // Make the cookie last a year
    servletResponse.addCookie(div);

    return "success";
  }

  // For access to the raw servlet request / response,eg for cookies
  protected HttpServletResponse servletResponse;
  @Override
  public void setServletResponse(HttpServletResponse servletResponse) {
    this.servletResponse = servletResponse;
  }

  protected HttpServletRequest servletRequest;
  @Override
  public void setServletRequest(HttpServletRequest servletRequest) {
    this.servletRequest = servletRequest;
  }
}

并且在struts.xml或web.xml中没有这个方法的配置,这是一个好处.所以我对这个解决方案感到满意,即使它在不好的光线下画了struts2.

java – 如何在struts2中仅获取响应中的特定字段

java – 如何在struts2中仅获取响应中的特定字段

我有一个动作类,其中定义了许多动作方法,并且还定义了适当的getter和setter方法.我有一些动作方法,我通过从jQuery调用它们来获取数据作为json.但是当我得到json数据时,它包含了定义了getter和setter的所有字段,但是我想只获得由我调用的那个方法填充的那个字段.例如-

public class ApplicantRegistration extends ActionSupport{
private String s1;
private XyzBean bean;
private String s2;
// respective getters and setters....

public String m1(){
// some work
 return SUCCESS;
}

public String m2(){
   //some work
    s2="abc";
    return SUCCESS;
}


}

当我通过jQuery调用方法m2并得到json响应时

{
 s1: null,
 bean: null,
 s2:"abc",
 m2: "success",

}

但我只想要

{
 s2:"abc"
}

解决方法:

默认情况下,json结果序列化root参数指定的所有bean属性,该参数默认设置为action.但是,您可以使用结果的includeProperties参数来仅过滤匹配正则表达式的根中的那些属性.

@Result(type="json", params = {"includeProperties", "^s2"})

今天的关于如何在Struts 2中使用if标记?struts2 if标签的分享已经结束,谢谢您的关注,如果想了解更多关于i18n在Struts2中使用拦截器、java – 在Struts 2中使用Ajax URL调用一个动作、java – 在Struts 2和Struts中使用cookies、java – 如何在struts2中仅获取响应中的特定字段的相关知识,请在本站进行查询。

在这篇文章中,我们将带领您了解如何在点击链接时创建iframe?的全貌,包括创建链接到本页的锚点的方法正确的事()的相关情况。同时,我们还将为您介绍有关Android上的Chrome解决方法在点击链接时未触发意图、asp.net – 如何在iframe中提交后刷新iframe父页面?、asp.net-mvc – 如何在点击电子邮件超链接时打开outlook、Facebook iframe链接仅在iframe内打开的知识,以帮助您更好地理解这个主题。

本文目录一览:

如何在点击链接时创建iframe?(创建链接到本页的锚点的方法正确的事())

如何在点击链接时创建iframe?(创建链接到本页的锚点的方法正确的事())

我有一个网页,表格内有几个链接。链接之一在td标签内。我想要一种调用iframe的方法,该iframe将在用户单击链接后打开。当iframe弹出时,页面的其余部分将变得无响应,并且一旦用户离开iframe,外部页面就会变得响应。表td是这样的:

<td ><a href="configuration.xml related jsp action">Set the Iframe up</a></td>

iframe将由另一个jsp的内容填充。

编辑: 我很着急,所以忘了粘贴我尝试过的代码:所以这里是:

<td ><a href="#">Set the Iframe up</a><div id="modalMan"><div><p><a href="#"><img src="cbutton.gif" alt="Close"/></a></p><iframe id="myFrame"height="430" width="675" src="myJSP.jsp" ></iframe></div></div></td>

但是,由于没有关闭图标,并且div的一部分

   <div id ="modalman">   <p class>   <iframe src>

所有内容都保持隐藏状态,并且iframe的外观类似,但是功能都变得混乱,myjsp的javascript内容保持隐藏状态。

再次编辑:
非常抱歉,我忘了提到我已经尝试过onclick功能,但是由于我的href是这样,所以它直接在新的浏览器选项卡中打开了jsp,而不是在iframe中打开它。

 <a href="configuration.xml related jsp action">Set the Iframe up</a>

我怎样才能做到这一点?请提出一种方法。

答案1

小编典典

继承人可以使用的非常基本的JavaScript函数。函数参数是您要将iFrame附加到的元素,以及它要指向的位置。

的HTML

<a href="#" onclick="setIframe(this,''http://www.stackoverflow.co.uk'')" >Set the Iframe up</a>

的JavaScript

function setIframe(element,location){    var theIframe = document.createElement("iframe");    theIframe.src = location;   element.appendChild(theIframe);}

Android上的Chrome解决方法在点击链接时未触发意图

Android上的Chrome解决方法在点击链接时未触发意图

我正在开发一个Android应用程序来处理某些http(s)链接的意图.它适用于大多数情况,但不适用于Chrome中的链接点击,因为this bug/missing feature.简而言之,Chrome不会广播这些点击的意图. :/

最终可能会修复,但与此同时,是否有人知道解决方法?

如果我自己控制链接,我可以使用自己的HTTP方案,例如myapp:// …,或者我可以use JavaScript to fake a button click,两者都发送意图……但我不控制链接.

具体来说,我想处理像http://github.com/snarfed这样的链接.我的活动在AndroidManifest.xml中的定义如下.它正确接收来自其他应用的这类链接点击的意向广播,而不是来自Chrome.

<activity android:name="MyApp" android:exported="true">
  <intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.broWSABLE" />
    <data android:scheme="http" />
    <data android:scheme="https" />
    <data android:host="github.com" />
  </intent-filter>
</activity>

解决方法:

您需要在每个数据点中包含scheme,host和pathPrefix.

适当清单的示例:

<activity
    android:name=".PhotostreamActivity"
    android:label="@string/application_name">

    <!-- ... -->            

    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.broWSABLE" />
        <data android:scheme="http"
              android:host="flickr.com"
              android:pathPrefix="/photos/" />
        <data android:scheme="http"
              android:host="www.flickr.com"
              android:pathPrefix="/photos/" />
    </intent-filter>
</activity>

此示例取自Romain Guy放在一起的应用程序,并在此处重复提问:

Intercepting links from the browser to open my Android app

需要注意的几点需要注意,似乎你需要在意图映射生效之前在背景中杀死Chrome.如果你直接输入网址,应用程序就不会被允许使用它,只有当它是Chrome提供的链接时应用程序的动作.

asp.net – 如何在iframe中提交后刷新iframe父页面?

asp.net – 如何在iframe中提交后刷新iframe父页面?

我在页面中有iframe,这个iframe包含一个提交按钮,可以执行某些功能.

我想要的是:在iframe提交完成后,调用父页面进行刷新.

我知道如何刷新它:

parent.location.reload();

但提交结束后我不知道怎么做.

解决方法

在iframe上使用onload事件处理程序.在提交后触发时,执行top.location.reload …
// In parent
window.onload = function() {
  document.getElementById("MY_IFRAME").onload = function() {
    top.location.reload();
  }
}

asp.net-mvc – 如何在点击电子邮件超链接时打开outlook

asp.net-mvc – 如何在点击电子邮件超链接时打开outlook

我有一张表,其中一列是电子邮件地址.
我需要添加一个指向此电子邮件地址的超链接,以便单击该链接打开Outlook,并在TO:字段中显示电子邮件地址.

有人可以帮忙吗?

解决方法

试试这个

<a href="mailto:abc@abc.com?Subject=ABC&Body=Body" title="title" >Email</a>

这里ABC是主题,电子邮件内容是正文.

Facebook iframe链接仅在iframe内打开

Facebook iframe链接仅在iframe内打开

如何解决Facebook iframe链接仅在iframe内打开?

| 我觉得人们一直在与这个问题相反,我无法弄清楚如何在fb之外而不是在iframe之外打开链接。.我正在发布驻留在服务器托管的FB应用程序中的资料。该页面具有指向其他站点的链接,但是当它们打开时,它们仍在facebook iframe中。 使用基本:
<a href= \"http....\"><b>Blank.com</b>
看起来像这样 点击链接... 我是菜鸟,任何帮助都会很棒。谢谢     

解决方法

        如果您已为iframe设置了一个应用程序,target = \“ _ blank \”将起作用。     ,        您是否尝试过“ 1”属性?
<a href=\"http://www.example.com\" target=\"_blank\">example.com</a>
    

今天关于如何在点击链接时创建iframe?创建链接到本页的锚点的方法正确的事()的分享就到这里,希望大家有所收获,若想了解更多关于Android上的Chrome解决方法在点击链接时未触发意图、asp.net – 如何在iframe中提交后刷新iframe父页面?、asp.net-mvc – 如何在点击电子邮件超链接时打开outlook、Facebook iframe链接仅在iframe内打开等相关知识,可以在本站进行查询。

本文标签: