servlet

【Spring框架】<mvc:default-servlet-handler/>的作用:过滤静态资源

╄→гoц情女王★ 提交于 2019-12-03 02:18:15
优雅REST风格的资源URL不希望带 .html 或 .do 等后缀.由于早期的Spring MVC不能很好地处理静态资源,所以在web.xml中配置DispatcherServlet的请求映射,往往使用 *.do 、 *.xhtml等方式。这就决定了请求URL必须是一个带后缀的URL,而无法采用真正的REST风格的URL。 如果将DispatcherServlet请求映射配置为"/",则Spring MVC将捕获Web容器所有的请求,包括静态资源的请求,Spring MVC会将它们当成一个普通请求处理,因此找不到对应处理器将导致错误。 如何让Spring框架能够捕获所有URL的请求,同时又将静态资源的请求转由Web容器处理,是可将DispatcherServlet的请求映射配置为"/"的前提。由于REST是Spring3.0最重要的功能之一,所以Spring团队很看重静态资源处理这项任务,给出了堪称经典的两种解决方案。 先调整web.xml中的DispatcherServlet的配置,使其可以捕获所有的请求: <servlet> <servlet-name>springMVC</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load

Sonarqube upgrade to 6.7: Unrecoverable indexation failures

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Currently we are in middle of upgrade process from v4.5.7 to v6.7.1. SonarQube is successfully upgraded to v5.6.7 (including DB upgrade) and currently in the process of updating to v6.7.1. New SonarQube version started on an empty DB ( bundled H2 DB ) worked fine. After which all the plugins and their versions are validated and updated accordingly. Now Sonar service launching is failing with error Background initialization failed. Stopping SonarQube java.lang.IllegalStateException: Unrecoverable indexation failures . I removed data/es5

FIXED: “No mapping found” Trying to set up a RESTfull interface using Spring-MVC

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This issue is solved. Someone created a file called mvc-dispatcher.xml and it had an incorrect configuration. That file is loaded automatically because it's called the same as a servlet. I want to thank everyone who tried to help me fix this issue. I'm keeping this question here, since it actually explains how to create a REST interface. It works perfectly. I'm trying to set up a RESTful interface with Spring-MVC. The server starts without issue, but any time I try to call the REST interface I get the message: 41 WARN [springframework.web

Spring, Hibernate Lazy Loading, sessionFactory, and OpenSessionInViewFilter

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using Hibernate's lazy loading, and am getting sessionFactory missing exception, even after I have defined a filter in web.xml to use OpenSessionInViewFilter <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- The definition of the Root Spring Container shared by all Servlets and Filters --> <context-param> <param-name

Getting HTTP Status 404 error when trying to run servlet [duplicate]

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question already has an answer here: Servlet returns “HTTP Status 404 The requested resource (/servlet) is not available” 1 answer I have a problem with my simple servlet that I am trying to run, Hello.java. I made it in eclipse, then placed the file it in the webapps/ServletTest/WEB-INF/classes folder and compiled it, creating the file Hello.class in the same folder. I then modified my web.xml file to map the servlet and tried to run it through the following address http://localhost:8080/ServletTest/Hello However, this did not work,

glassfish-web.xml vs sun-web.xml vs web.xml

匿名 (未验证) 提交于 2019-12-03 02:13:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Could someone explain the main differences (or provide a link to) between glassfish-web.xml , sun-web.xml and web.xml ? Can I use just glassfish-web.xml in my webapp and skip the others? 回答1: web.xml : Standard deployment descriptor defined by Java EE (Servlet JSR in particular, but used by many JSRs). It is used to specify the metadata used by the web container to deploy the application in a portable manner across application servers (such as the URL endpoint of a servlet). In Java EE 6 and beyond, it is optional (depending on technologies

@WebServlet annotation doesn't work with Tomcat 8

匿名 (未验证) 提交于 2019-12-03 02:13:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 选择语言 中文(简体) 日语 英语 中文(繁体) 由 翻译 强力驱动 问题: I want to use the @WebServlet annotation in a Java EE webapp which runs on Tomcat 8. I have read that I need to declare Servlet Version 3.1 in my web.xml and that my Servlet needs to extend HttpServlet . I did all that but still the @WebServlet doesn't work. I am getting a HTTP 404. I also tried my configuration with metadata-complete="false" in my web.xml , but still no success. Here is my web.xml and Servlet. The complete sample code can be found on GitHub . web.xml <? xml version = "1.0" encoding = "UTF

Could not open ServletContext resource [/WEB-INF/applicationContext.xml]

匿名 (未验证) 提交于 2019-12-03 02:13:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Ok, I am 500th user asking this question, I read many answers but still having no luck. parent module pom contains: <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.framework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.framework.version}</version> </dependency> Child module has maven-jetty-plugin and I run my webapp module with jetty:run . web.xml defines standard dispatcher module:

java.lang.IllegalArgumentException: The main resource set specified […] is not valid

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm having trouble starting my Tomcat server, it used to work, but I did something wrong and now it throws me this exception: Caused by : java . lang . IllegalArgumentException : The main resource set specified [ E : \workspace\.metadata\.plugins\org . eclipse . wst . server . core\tmp1\wtpwebapps\workspace\j 2eeapplication \target\j 2eeapplication - 0.0 . 1 - SNAPSHOT ] is not valid at org . apache . catalina . webresources . StandardRoot . startInternal ( StandardRoot . java : 643 ) at org . apache . catalina . util .

java.lang.RuntimeException Cannot find FacesContext

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I don't know how to continue, but I always get the "java.lang.RuntimeException: Cannot find FacesContext" for my new JSF 1.2 web application. I'm sure it's just some configuration I can't find. The exception occurs with the first f: or h: tag. Already with the important <f:view> at the beginning. My index.jsp <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">