小编ahp*_*ete的帖子

在Java Servlet中转发请求时的无限循环

我希望你能帮助我解决我面临的这个问题:

我使用NetBeans创建了一个简单的Web应用程序.截至目前,这是非常基本的.

  1. servlet接收/verificon/*url模式的请求.
  2. 它提取后面设置的任何字符串/verificon/,即如果网址是http://domain/context/verificon/blahblah,则提取blahblah.
  3. 它检查这样的字符串是否是已知字符串,并只显示带有结果的jsp(true/false).

但是,尽管很简单,但在使用测试字符串运行应用程序时出现以下错误:

javax.servlet.ServletException: 
The server side component of the HTTP Monitor has detected a java.lang.StackOverflowError.
This happens when there is an infinite loop in the web module.
Correct the cause of the infinite loop before running the web module again.

org.netbeans.modules.web.monitor.server.MonitorFilter.rethrow(MonitorFilter.java:1648)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:473)
mx.tegu.kdor.web.iu.ServletVerificon.processRequest(ServletVerificon.java:51)
mx.tegu.kdor.web.iu.ServletVerificon.doGet(ServletVerificon.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
mx.tegu.kdor.web.iu.ServletVerificon.processRequest(ServletVerificon.java:51)
mx.tegu.kdor.web.iu.ServletVerificon.doGet(ServletVerificon.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
mx.tegu.kdor.web.iu.ServletVerificon.processRequest(ServletVerificon.java:51)
mx.tegu.kdor.web.iu.ServletVerificon.doGet(ServletVerificon.java:70)
    ...
Run Code Online (Sandbox Code Playgroud)

然后它不断重复自己.

我的servlet的processRequest方法如下.TestData只是一个辅助类,Mapeo如果字符串已知或不null存在,则返回一个对象.

protected void processRequest(HttpServletRequest request, HttpServletResponse …
Run Code Online (Sandbox Code Playgroud)

servlets java-7 tomcat7

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

在C#中使用DrawString对文本进行对齐

我在一个System.Drawing.Graphics物体上画文字.我正在使用该DrawString方法,使用文本字符串,a Font,a Brush,a bounding RectangleF和a StringFormat参数.

调查一下StringFormat,我发现我可以将它的Alignment属性设置为Near,CenterFar.但是我还没有找到将它设置为Justified的方法.我怎样才能做到这一点?

谢谢您的帮助!

c# system.drawing

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

提升线程串行运行,而不是并行运行

我是C++中多线程的完全新手,并决定从Boost Libraries开始.另外,我在Vista上使用英特尔的C++编译器(来自Parallel Studio 2011)和VS2010.

我正在编写一个遗传算法,并希望利用多线程的好处:我想为人口中的每个人(对象)创建一个线程,以便他们并行计算他们的适应度(重度操作),减少总执行时间.

据我所知,每当我启动一个子线程时,它就会"在后台"工作,而父线程继续执行下一条指令,对吧?所以,我想到创建并启动我需要的所有子线程(在for循环中),然后等待它们完成(join()在另一个for循环中调用每个线程),然后再继续.

我面临的问题是第一个循环不会继续下一次迭代,直到新创建的线程完成工作.然后,第二个循环就像去了一样好,因为所有的线程都已经被循环命中时加入了.

这是(我认为是)相关的代码片段.告诉我你还有什么需要知道的.

class Poblacion {
    // Constructors, destructor and other members
    // ...
    list<Individuo> _individuos;
    void generaInicial() { // This method sets up the initial population.
        int i;
        // First loop
        for(i = 0; i < _tamano_total; i++) {
            Individuo nuevo(true);
            nuevo.Start(); // Create and launch new thread
            _individuos.push_back(nuevo);
        }

        // Second loop
        list<Individuo>::iterator it;
        for(it = _individuos.begin(); it != _individuos.end(); it++) {
            it->Join();
        }

        _individuos.sort();
    }
}; …
Run Code Online (Sandbox Code Playgroud)

c++ parallel-processing multithreading boost-thread

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

Spring在注入参数时尝试实例化接口

我希望你能帮助我.

我在我的Web应用程序中使用Spring MVC(3.1.1),并且面临着一种奇怪的情况.我有这个简单的@Controller,它使用ServicioUsuario服务,并且工作正常:

@Controller
@RequestMapping("/ajax")
public class ControladorAjax extends ControladorGenerico {

  @Autowired
  ServicioUsuario servicioUsuario;

  @RequestMapping("/check")
  public ResponseEntity<String> check(@RequestParam String email) {
    // Declarations and other operations omitted...
    // Use servicioUsuario
    servicioUsuario.doStuff();
    return response;
  }
}
Run Code Online (Sandbox Code Playgroud)

但是,如果我删除@Autowiring,并尝试将Spring inject servicioUsuario作为参数(即通过将方法签名更改为:),public ResponseEntity<String> check(@RequestParam String email, ServicioUsuario servicioUsuario)整个事情就会中断,我在Tomcat的日志中得到了这种异常:

javax.servlet.ServletException: NestedServletException in java.lang.Thread.getStackTrace:: Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.package.ServicioUsuario]: Specified class is an interface
Run Code Online (Sandbox Code Playgroud)

我有这些接口:

com.package
  |-> Servicio.java (interface)
  |-> ServicioUsuario.java (interface that extends Servicio) …
Run Code Online (Sandbox Code Playgroud)

spring spring-mvc

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