问题标签 [static-block]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
381 浏览

tomcat - How to log in the static block for a jar library

i have the following situation:

  • We have a common library (made by our organization) that have some class that is static (because for optimization have many records in memory) and it's deployed in the lib directory of the tomcat (to be accesed to all webapps deployed).
  • The static class need to access to DB conection, and for that (if there any problem) we use log4j, but that aproach generate the following problem:

log4j:WARN No appenders could be found for logger (dev.sample.test.TestLog4J). log4j:WARN Please initialize the log4j system properly.

This problem it's well documented at: https://wiki.apache.org/commons/Logging/StaticLog but don't have a clean fix to this problem (like some configuration in the logging.properties file of the tomcat server)

The code of the java class that is logging is very simple:

So, what are the choices? It's seem a little ugly do the "logging" with System.out.println(...), so i hope that maybe are some work around to this problem using log4j.

Regards, and thx for your's answers :)

0 投票
1 回答
132 浏览

magento - Magento 属性显示在下拉菜单中

我在我的网上商店中设置了不同的属性。

现在好了,只有在我的下拉菜单中显示了属性模型、品牌和类别。有可能,怎么做?

0 投票
1 回答
111 浏览

java - 静态块与静态变量初始化顺序

方案 1:

输出:999

场景二:

输出:56789

在场景 2 中,它如何为 foo 变量(在静态块中)分配内存,因为没有提到任何数据类型(因为代码从上到下运行)。

0 投票
1 回答
559 浏览

css - Magento:如何在magento中的所有产品列表和侧边栏结束之后放置已经创建的静态块?

我在 magento 中有 2 列左侧边栏主题。我已经创建了 3 个静态块。现在我想在所有产品列表之后和页脚之前显示这些块。我能怎么做 ?

我已经尝试过了,但是这些块与新产品混在一起了。

0 投票
1 回答
217 浏览

magento - 在 Magento 中定位默认的静态块内容

我对 Magento 1.9.0.1 中的“Footer Links Company”静态块进行了更改,需要恢复为默认内容。如何找到此块中的原始 HTML?

0 投票
0 回答
109 浏览

magento - Magento:更改语言时块消失

我用我的 Magento 网站创建了一个自定义主题,在我的主题中,我有一个滑块和一些其他块,但是如果我单击并更改语言,我的主页块就会消失,我不知道为什么,我查看了配置 -> 我的语言商店和 Web 选项卡中的“所有视图商店”都是一样的,所以我想他们采用相同的选项和页面,所以我所有的块!我不知道我还要看哪里,有人可以给我一些建议吗?非常感谢!干杯!

0 投票
3 回答
502 浏览

java - 在不实例化类的情况下运行静态块 - Java

我有几个子类扩展了一个抽象父类。我希望父类有一个静态 ArrayList 持有每个孩子的实例。如果可能的话,我希望能够添加更多的子类,而不必更改父类的代码。

我想出的一个解决方案是给每个子类一个静态块,它将自己的一个实例添加到 ArrayList。唯一的问题是我需要对每个孩子进行一些调用以使其加载并运行该块。

有没有解决的办法?我可以加载一个类而不调用它吗?有没有更好的方法来做到这一点?

编辑:这实际上是针对基于瓷砖的游戏。我有一个抽象的“瓷砖”类和任意数量的瓷砖类型扩展它。我希望能够轻松地向游戏中添加新图块,而无需到处更改代码。如果您对如何执行此操作有更好的想法,我愿意接受建议。

0 投票
2 回答
724 浏览

magento - 商店中具有不同内容的 Magento 商店静态块

因此,当您阅读标题时,我需要有关 magento 静态块的帮助,我的任务是使静态块内容在 2 个商店中有所不同,如果可能的话?求答案。PS对不起英语不好。

0 投票
1 回答
423 浏览

java - 从另一个项目加载 xml 文件

我编写了一个带有静态块的 java 类来读取项目 A 中的 xml。此外,我还向 B 中添加了项目 A 的依赖项,该依赖项需要来自 xml 的数据。但是当我尝试使用 A 中的 readerclass 读取 xml 时,我收到一条错误消息,指出文件未找到异常为“...../B/web-inf/lib/A.jar!/data.xml”。由于 xml 文件在阅读器 jar 中,我无法继续。项目 A 中的静态块仅在项目 B 的第一次请求期间执行,

项目A代码:

请帮我解决这个问题......

0 投票
1 回答
2812 浏览

java - 为什么我们不能通过类名在静态块中设置静态最终变量的值

例如,考虑下面的代码快照:

为什么我们不能在类本身Test.b = 10;的静态块中使用?Test没有类名它工作正常。

这背后有什么原因吗?