问题列表 - 第28674页

X-Cache标头说明

我正在浏览firefox本地缓存文件夹,发现很多文件包含X-cache头文件.有人可以解释这个标题的目的吗?

谢谢

caching http http-headers

25
推荐指数
3
解决办法
4万
查看次数

请解释Thread run()和start()方法的输出

请解释以下代码的输出:

如果我打电话th1.run(),输出是:

EXTENDS RUN>>
RUNNABLE RUN>>
Run Code Online (Sandbox Code Playgroud)

如果我打电话th1.start(),输出是:

RUNNABLE RUN>>
EXTENDS RUN>>
Run Code Online (Sandbox Code Playgroud)

为什么这种不一致?请解释.

class ThreadExample extends Thread{
    public void run() {
        System.out.println("EXTENDS RUN>>");
    }
}

class ThreadExampleRunnable implements Runnable {
    public void run() {
        System.out.println("RUNNABLE RUN>>");
    }
}

class ThreadExampleMain{
    public static void main(String[] args) {
        ThreadExample th1 = new ThreadExample();
        //th1.start(); 
        th1.run();

        ThreadExampleRunnable th2 = new ThreadExampleRunnable();
        th2.run();
    }
}
Run Code Online (Sandbox Code Playgroud)

java multithreading

9
推荐指数
1
解决办法
6909
查看次数

多个选择删除多个选项时出现问题

好吧,Opera代码浏览器似乎存在问题,因为它只删除了在多选标记中选择的最后一个选项标记,有人可以帮助我.

这是以下HTML:

<select id="actions_list" name="layouts" multiple style="height: 128px; width: 300px;">
    <option value="forum">forum</option>
    <option value="collapse">collapse</option>
    <option value="[topic]">[topic]</option>
    <option value="[board]">[board]</option>
</select>
Run Code Online (Sandbox Code Playgroud)

当然它在一个表单标签中,但是这个表单涉及的代码更多,但这里有相关的信息.

这是应该处理这个问题的JS,但只删除Opera中最后选择的选项,不确定其他浏览器,但它确实需要删除所有选定的选项,而不仅仅是最后选择的选项... argg

var action_list = document.getElementById("actions_list");
var i = action_list.options.length;
while(i--)
{
    if (action_list.options[i].selected)
    {
        action_list.remove(i);
    }
}
Run Code Online (Sandbox Code Playgroud)

这有什么问题?我想不出来一点:(

谢谢 :)

javascript select options multiple-select

6
推荐指数
2
解决办法
1万
查看次数

当transactionManager未命名为"transactionManager"时

我正在尝试Spring 3(.0.2.RELEASE)和JPA2和Hibernate 3.5.1-Final ...有一点让我感到不安的是,spring似乎只接受名为"transactionManager"的事务管理器

如果我没有将它命名为"transactionManager",Spring将抛出NoSuchBeanDefinitionException:没有定义名为'transactionManager'的bean.

这是我的配置:

<context:component-scan base-package="destiny.data.mining"/>

<context:annotation-config/>

<bean id="miningEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
  <property name="persistenceUnitName" value="mining"/>
</bean>

<bean id="miningTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" >
  <property name="entityManagerFactory" ref="miningEntityManagerFactory"/>
</bean>

<tx:advice id="txAdviceMining" transaction-manager="miningTransactionManager">
  <tx:attributes>
    <tx:method name="get*"    read-only="true"/>
    <tx:method name="save*"   propagation="REQUIRED"/>
    <tx:method name="update*" propagation="REQUIRED"/>
    <tx:method name="delete*" propagation="REQUIRED"/>
    <tx:method name="*" propagation="SUPPORTS" read-only="true"/>
  </tx:attributes>
</tx:advice>  

<aop:config>
  <aop:pointcut id="methods" expression="execution(* destiny.utils.AbstractDao+.*(..))"/>
  <aop:advisor advice-ref="txAdviceMining" pointcut-ref="methods"/>
</aop:config>

<tx:annotation-driven transaction-manager="miningTransactionManager"/>  
Run Code Online (Sandbox Code Playgroud)

在这种配置,实体管理器工厂是不是一定名为"entityManagerFactory的"和"txAdvice"是不是一定名为"txAdvice",无论是.但我不知道为什么Spring上需要一个名为"transactionManager"的事务管理器?

有没有办法不命名事务管理器"transactionManager"? (我正在运行多个spring配置文件,所以我尽量避免名称冲突)

测试代码:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:mining.xml"})
public class MiningPersonDaoTest
{
  @Inject
  private EntityManagerFactory miningEntityManagerFactory;

  @Inject …
Run Code Online (Sandbox Code Playgroud)

java spring unit-testing transactions

5
推荐指数
1
解决办法
6225
查看次数

如何在grep中进行非贪婪的比赛?

我想grey最短的比赛,模式应该是这样的:

<car ... model=BMW ...>
...
...
...
</car>
Run Code Online (Sandbox Code Playgroud)

...表示任何字符,输入是多行.

regex shell command-line grep regex-greedy

166
推荐指数
5
解决办法
11万
查看次数

java主要功能

public static void main()&public void main()什么是这两者之间的区别?

java

1
推荐指数
1
解决办法
705
查看次数

从每个起点删除N行

如何从我看到的单词的每个实例开始删除6行?

linux scripting perl

4
推荐指数
1
解决办法
134
查看次数

Java中游戏实体位置的有效映射

在Java(Swing)中,假设我有一个2D游戏,我在屏幕上有各种类型的实体,例如玩家,坏人,通电等.当玩家在屏幕上移动时,为了做到高效检查玩家附近的内容,我认为我希望根据他们的位置索引访问角色附近的东西.

例如,如果玩家'P'在以下示例中进入元素'E'...

| | | | | |
| | | |P| |
| | |E| | |
| | | | | |
Run Code Online (Sandbox Code Playgroud)

......会做类似的事情:

if(player.getPosition().x == entity.getPosition().x && 
              entity.getPosition.y == thing.getPosition().y)
{
    //do something
}
Run Code Online (Sandbox Code Playgroud)

这很好,但这意味着实体保持其位置,因此,如果我在屏幕上有许多实体,我将不得不循环遍历所有可用的实体并检查每个位置与玩家位置.这似乎真的很低效,特别是如果你开始获得大量的实体.

所以,我怀疑我想要某种类似的地图

Map<Point, Entity> map = new HashMap<Point, Entity>();
Run Code Online (Sandbox Code Playgroud)

并将我的点信息存储在那里,以便我可以在恒定时间内访问这些实体.该方法的唯一问题是,如果我想将实体移动到屏幕上的不同点,我将不得不搜索HashMap的值以寻找我想要移动的实体(因为我不知道它的效率低效)提前点位置),然后一旦我发现它从HashMap中删除它,然后用新的位置信息重新插入它.

有关我应该使用何种数据结构/存储格式的建议或建议,以便根据实体的位置有效访问实体,以及基于实体的职位?

java algorithm dictionary data-structures

7
推荐指数
1
解决办法
1087
查看次数

基于Yii的CMS?

我已经和Yii呆了几个月,之后我在我的项目中使用了主要的CodeIgniter,SilverStripe.有没有人知道一个好的基于Yii的CMS,例如基于Sapphire的SilverStripe或基于CodeIgniter的EE?

假设你是优秀的OOP编码器,我的经验是与Yii合作更容易和直接,但是Yii还很年轻,并且没有很多样本我可以快速组合起来进行真正的生产项目.

我发现的几个基于YII的CMS看起来并不是很有前途,或者可能处于非常早期的阶段,例如dotPlant,Web3CMS.

php yii content-management-system

28
推荐指数
3
解决办法
3万
查看次数

我可以弹出特定ViewController吗?

我正在使用导航应用程序.我将First ViewController推送到Second ViewController,从Second ViewController推送到Third ViewController.现在我想从Third ViewController弹出到First ViewController.我正在使用下面的代码执行此任务,但我的应用程序崩溃了.

请任何机构给我一些适当的指导.我不能使用pop到rootViewController,因为它是不同的viewController.提前致谢...

在第三个ViewControler中我写了这个:

FirstViewCtr *x=[[FirstViewCtr alloc] initWithNibName:@"FirstViewCtr" bundle:nil];
[self.navigationController popToViewController:x animated:NO];
Run Code Online (Sandbox Code Playgroud)

iphone uinavigationcontroller popviewcontroller

48
推荐指数
7
解决办法
4万
查看次数