草庐IT

servlet-listeners

全部标签

java - 原始 Servlet 与 Spring MVC

关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题吗?更新问题,以便editingthispost提供事实和引用来回答它.关闭7年前。Improvethisquestion您应该使用原始JavaServlet或使用SpringMVC(或任何其他框架)构建Web应用程序的原因是什么?应该避免使用SpringMVC是否有异常(exception),使用RawServlet有什么好处? 最佳答案 如果您正在构建一个非常快速且肮脏的演示,并且您以后不打算扩展,那么Spring可能会导致许多额外的配置问题(如果您以

java - Spring 注入(inject)到 Servlet

所以我看到了这个问题:Springdependencyinjectiontootherinstance想知道我的方法是否可行。1)在我的Spring应用程序上下文中声明bean2)覆盖我的servlet的init方法,如图所示:@Overridepublicvoidinit(ServletConfigconfig)throwsServletException{super.init(config);ApplicationContextac=newClassPathXmlApplicationContext("applicationContext.xml");this.apiData=(A

spring - 从 Spring Web 应用程序中检索 servlet 上下文路径

我希望能够动态检索“servlet上下文路径”(例如http://localhost/myapp或http://www.mysite.com)用于来自Servicespringbean的SpringWeb应用程序。这样做的原因是我想在将要发送给网站用户的电子邮件中使用此值。虽然从SpringMVCController执行此操作很容易,但从Servicebean执行此操作并不那么明显。谁能给点建议?编辑:附加要求:我想知道是否有一种方法可以在应用程序启动时检索上下文路径并让我的所有服务始终可以检索它? 最佳答案 如果您使用Servle

spring - 在不重启 servlet 容器的情况下重新加载/刷新 Spring 配置文件

如何在不重启servlet容器的情况下刷新Spring配置文件?我正在寻找JRebel以外的解决方案。 最佳答案 对于那些最近遇到这个问题的人来说——目前解决这个问题的现代方法是使用SpringBoot'sCloudConfig.只需添加@RefreshScope可刷新bean和@EnableConfigServer上的注释在您的主要/配置上。例如,这个Controller类:@RefreshScope@RestControllerclassMessageRestController{@Value("${message}")priv

java - 如何在 servlet 过滤器中获取 Spring bean?

我已经定义了一个javax.servlet.Filter并且我有带有Spring注释的Java类。importorg.springframework.context.annotation.Configuration;importorg.springframework.context.annotation.Bean;@ConfigurationpublicclassSocialConfig{//...@BeanpublicUsersConnectionRepositoryusersConnectionRepository(){//...}}我想在我的Filter中获取beanUsersC

spring - java.lang.IllegalArgumentException : A ServletContext is required to configure default servlet handling

我有以下测试类:@ActiveProfiles({"DataTC","test"})@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(classes={BaseTestConfiguration.class,DataTestConfiguration.class,JpaConfiguration.class,PropertyPlaceholderConfiguration.class})publicclassRegularDayToTimeSlotsTest{...问题似乎来自BaseTestConfigurati

spring - javax.servlet.ServletException 无法解析为 Spring Web 应用程序中的类型

这个问题在这里已经有了答案:HowdoIimportthejavax.servlet/jakarta.servletAPIinmyEclipseproject?(16个答案)关闭2年前。我正在使用spring框架开发web应用程序,但在某些jsp页面中出现以下错误。javax.servlet.ServletExceptioncannotberesolvedtoatype我也包含了servlet-api但仍然显示相同的错误消息。如何克服这个问题? 最佳答案 我想这可能可行,在Eclipse选择您的项目→然后点击顶部的项目菜单栏→转到属

spring - java.lang.ClassNotFoundException : org. springframework.web.servlet.DispatcherServlet

我正在使用spring3.1.0.RELEASE,我的servlet容器是tomcat7,我的IDE是eclipseindigo以及包含DispatcherServlet的jarspring-webmvc-3.1.0.RELEASE.jar存在于lib文件夹中,但是在运行应用程序时,我得到了异常:java.lang.ClassNotFoundException:org.springframework.web.servlet.DispatcherServletatorg.apache.catalina.loader.WebappClassLoader.loadClass(WebappCl

dart - 如何在 EventChannel.listen 的回调 onEvent 中显示 SnackBar

使用EventChannel从native代码接收事件。内容是字符串,我想用SnackBar显示它。但是Scaffold.of返回null。并且我没有找到由WidgetBuild(...)创建的Scaffold的BuildContext。代码是这样的:@overridevoidinitState(){super.initState();showMsg.receiveBroadcastStream().listen((event)=>setState((){Scaffold.of(context).showSnackBar(newSnackBar(content:newText(even

sockets - 使用 Socket.io 构建 Flutter 应用程序 : can't listen to or emit msgs to the socket channel

我正在使用带有flutter的adhara套接字io来构建套接字应用程序。https://pub.dartlang.org/packages/adhara_socket_io套接字成功连接,但没有监听或向我拥有的事件发送任何数据。我从Web客户端进行了测试,一切正常。这是我正在使用的库提供的示例代码:import'package:flutter/material.dart';import'dart:convert';import'package:adhara_socket_io/adhara_socket_io.dart';voidmain()=>runApp(MyApp());con