小编Rit*_*yak的帖子

如何从我的eclipse项目中删除javascript验证?

我在我的项目中使用eclipse,在弄乱我的eclipse设置时,我启用了Javascript支持.现在eclipse抱怨JQuery库中有错误,并且不让我编译项目.有谁知道如何关闭javascript验证?

javascript eclipse validation syntax jquery

354
推荐指数
4
解决办法
21万
查看次数

在Tomcat中从servlet生成线程的推荐方法是什么

可能重复一次!我使用Tomcat作为我的服务器,并想知道什么是在确定性结果的servlet中生成线程的最佳方法.我正在从servlet操作运行一些长时间运行的更新,并希望完成请求并在后台进行更新.而不是添加像RabbitMQ这样的消息中间件,我想我可以生成一个可以在后台运行并在自己的时间内完成的线程.我在其他SO线程中读到服务器终止服务器生成的线程,以便它能够很好地管理资源.

在使用Tomcat时是否有推荐的方法来生成线程,后台作业.我还使用Spring MVC作为应用程序.

java multithreading tomcat servlets spring-mvc

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

批处理文件运行时更改

我正在运行一个长期运行的批处理文件.我现在意识到我必须在批处理文件的末尾添加更多命令(不需要更改现有内容,只需要一些额外的命令).是否可以这样做,因为大多数批处理文件是逐步读取并逐个执行的?或者系统是否读取文件的全部内容然后运行作业?

windows batch-file

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

Gravatar:有默认图片吗?

我已经为我正在构建的门户网站实现了gravatar,并想知道是否有gravatar的默认图片网址?并非所有访问该网站的人都已登录或拥有电子邮件地址,在这种情况下,是否有可以显示的默认图像(可通过gravatar url访问)

default gravatar image

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

Grails:我如何模拟测试中可能在内部调用的类的其他方法

我正在类似于下面给出的服务类中为methodA()编写测试.

Class SampleService {
  def methodA(){
     methodB()
  }

  def methodB(){
  }
}
Run Code Online (Sandbox Code Playgroud)

当我测试methodA()时,我需要能够在测试methodA()时模拟对methodB()的调用.我使用的是版本2.0.x的grails.在1.3.x发行版中,我会写一个像这样的自我模拟

def sampleServiceMock = mockFor(SampleService) 
sampleServiceMock.demand.methodB { -> } 
Run Code Online (Sandbox Code Playgroud)

但这在2.0.x版本中不起作用.我想知道在测试methodA()时模拟methodB()的其他方法是什么

testing tdd grails groovy mocking

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

运行shell脚本为./script.sh和sh script.sh之间的区别是什么

我有一个看起来像这样的脚本

#!/bin/bash

function something() {
 echo "hello world!!"
}

something | tee logfile 
Run Code Online (Sandbox Code Playgroud)

我已经为这个文件设置了执行权限,当我尝试像这样运行文件时

 $./script.sh
Run Code Online (Sandbox Code Playgroud)

它运行得很好,但是当我在命令行上运行它时,就像这样

$sh script.sh 
Run Code Online (Sandbox Code Playgroud)

它引发了一个错误.为什么会发生这种情况,以及解决这个问题的方法是什么.

unix shell scripting

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

如何实现真正的异步java线程

我有一个需要执行两个操作的函数,一个快速完成,另一个需要很长时间才能运行.我希望能够将长时间运行的操作委托给一个线程,我不在乎线程何时完成,但线程需要完成.我实现了如下所示,但是,我的第二次操作永远不会完成,因为函数在start()调用之后退出.我如何确保函数返回但第二个操作线程也完成其执行并且不依赖于父线程?

public void someFunction(String data)
{
   smallOperation()
   SecondOperation a = new SecondOperation();
   Thread th = new Thread(a);
   th.Start();
}

class SecondOperation implements Runnable
{
  public void run(){
  // doSomething long running
 }
} 
Run Code Online (Sandbox Code Playgroud)

java multithreading asynchronous runnable

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

Spring 3安全性:未调用AccessDeniedHandler

我有一个spring 3应用程序,其配置如下.当任何用户尝试访问某个页面并且他/她未登录时,我会收到一个带有丑陋堆栈跟踪的Access is Denied异常.如何处理此异常并且不允许它转储堆栈跟踪.我实现了自己的访问被拒绝处理程序但不会被调用.

根据所请求资源的类型,我想显示自定义错误消息或页面.这是我的弹簧配置.

如何让Spring调用我的访问被拒绝处理程序.这是我的弹簧配置

 <security:http auto-config='true'>
    <security:intercept-url pattern="/static/**" filters="none"/>
    <security:intercept-url pattern="/login" filters="none"/>

      <security:intercept-url pattern="/**" access="ROLE_USER" />

      <security:form-login login-page="/index"
            default-target-url="/home" always-use-default-target="true"
            authentication-success-handler-ref="AuthenticationSuccessHandler"        
            login-processing-url="/j_spring_security_check" 
            authentication-failure-url="/index?error=true"/>

       <security:remember-me key="myLongSecretCookieKey" token-validity-seconds="1296000" 
            data-source-ref="jdbcDataSource" user-service-ref="AppUserDetailsService" />

       <security:access-denied-handler ref="myAccessDeniedHandler" />   

    </security:http>

    <bean id="myAccessDeniedHandler"
         class="web.exceptions.handlers.AccessDeniedExceptionHandler">
      <property name="errorPage" value="/public/403.htm" />
    </bean>
Run Code Online (Sandbox Code Playgroud)

下面给出了处理此异常的自定义类

public class AccessDeniedExceptionHandler implements AccessDeniedHandler
{

    private String errorPage;

    @Override
    public void handle(HttpServletRequest request, HttpServletResponse response,
            AccessDeniedException arg2) throws IOException, ServletException {
        response.sendRedirect(errorPage);
    }

       public void setErrorPage(String errorPage) {
       if ((errorPage != null) && …
Run Code Online (Sandbox Code Playgroud)

java spring-mvc spring-security spring-3

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

使用JS如何阻止子iframe重定向或至少提示用户有关重定向

许多站点都有类似下面的脚本.这些都是为了阻止其他人构建网站.

if (top.location != location) {
  top.location.href = document.location.href;
}
Run Code Online (Sandbox Code Playgroud)

我需要一些方法来实现iframe尝试重定向,如果是,我将删除iFrame,而是放置一个链接到该网站.这样,我不违反框架网站的使用政策,也链接到该网站.我知道你可以使用这里这里讨论过的onbeforeunload事件,但两者看起来都是不道德的.我记得在某个地方读过一个完全相同的东西(digg做同样的事情).任何线索?

javascript iframe redirect

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

Grails:向message.properties添加新属性时出现Native2ascii错误

我在运行时在grails应用程序中向message.properties文件添加新属性时出现了一个奇怪的错误.当我通过命令行重新启动应用程序,或重新启动STS时,此错误消失.我在2.0.1版本上,直到一周前,我能够在运行时向message.properties文件中添加新属性.这是错误的堆栈跟踪

| Error 2012-06-18 16:54:58,702 [Thread-38] ERROR plugins.AbstractGrailsPluginManager  - Plugin [i18n:2.0.1] could not reload changes to file [/home/project/grails-app/i18n/messages.properties]: Error starting Sun's native2ascii: 
Message: Error starting Sun's native2ascii: 
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

grails properties internationalization sts-springsourcetoolsuite

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