Web applications 没有xml配置和url映射web应用程序

Web applications 没有xml配置和url映射web应用程序,web-applications,spring-mvc,tomcat7,jboss7.x,url-mapping,Web Applications,Spring Mvc,Tomcat7,Jboss7.x,Url Mapping,这是我的第一篇帖子,所以对我放松点。我正试图在JBossAS7和或Tomcat7上使用SpringWebMVC3.1.3建立一个JavaWeb应用程序。但是在URL映射中发生了一些奇怪的事情。我正在学习一系列的教程,但我基本上是在做本教程的第一部分。在我的WEB-INF/views文件夹中有一个非常简单的jsp,我希望在调用http://localhost:8080/hello/welcome。但这并没有发生。url映射有问题。当我使用像/test/*这样的东西并调用http://localho

这是我的第一篇帖子,所以对我放松点。我正试图在JBossAS7和或Tomcat7上使用SpringWebMVC3.1.3建立一个JavaWeb应用程序。但是在URL映射中发生了一些奇怪的事情。我正在学习一系列的教程,但我基本上是在做本教程的第一部分。在我的WEB-INF/views文件夹中有一个非常简单的jsp,我希望在调用
http://localhost:8080/hello/welcome
。但这并没有发生。url映射有问题。当我使用像/test/*这样的东西并调用
http://localhost:8080/hello/test/welcome
它按预期工作。当我使用/*
http://localhost:8080/hello/welcome
返回未呈现的jsp。当我使用我在noob看来应该是默认的404资源时,我得到了一个找不到的404资源。 我在JBoss 7.1.1和Tomcat 7.0.33服务器上测试了这一切,该服务器在eclipse中运行或使用war文件部署。我束手无策。每一个谷歌搜索结果页面都充满了紫色链接,我还没有找到我要找的内容

有人能帮忙吗?我知道有些信息可能丢失,但请询问

编辑:我忘了我使用maven来构建我的应用程序。这是使用用于eclipse的m2e wtp插件完成的。我正在运行EclipseJuno

这是我的初始值设定项(非常基本)

这是我的WebappConfig:

@Configuration
@ComponentScan("nl.hello")
@EnableWebMvc
public class WebappConfig extends WebMvcConfigurerAdapter
{
@Bean
public InternalResourceViewResolver setupViewResolver() 
{
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/views/");
resolver.setSuffix(".jsp");

return resolver;
}

@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer{
configurer.enable();
}}
以及控制器:

@Controller
public class HelloController {

@RequestMapping("/welcome")
public String helloWorld(Model model) {
//let’s pass some variables to the view script
model.addAttribute("wisdom", "Goodbye XML");

return "welcome"; 
}}
还有我的pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>hello</groupId>
<artifactId>hello</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
  <plugins>
    <plugin>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>2.3.2</version>
      <configuration>
        <source>1.6</source>
        <target>1.6</target>
      </configuration>
    </plugin>
    <plugin>
      <artifactId>maven-war-plugin</artifactId>
      <version>2.3</version>
      <configuration>
        <failOnMissingWebXml>false</failOnMissingWebXml>
      </configuration>
    </plugin>
  </plugins>
</build>
<properties>
    <project.build.sourceEncoding>utf8</project.build.sourceEncoding>
</properties>
<dependencies>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.1.8.Final</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>3.1.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>3.1.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
    <groupId>javax.inject</groupId>
    <artifactId>javax.inject</artifactId>
    <version>1</version>
</dependency>
<dependency>
    <groupId>cglib</groupId>
    <artifactId>cglib</artifactId>
    <version>2.2.2</version>
</dependency>
 </dependencies>
 </project>

4.0.0
你好
你好
0.0.1-快照
战争
maven编译器插件
2.3.2
1.6
1.6
maven战争插件
2.3
假的
utf8
org.hibernate
休眠实体管理器
4.1.8.最终版本
org.springframework
春季甲虫
3.1.3.1发布
org.springframework
SpringWebMVC
3.1.3.1发布
javax.servlet
javax.servlet-api
3.0.1
假如
javax.inject
javax.inject
1.
cglib
cglib
2.2.2

我解决了!我应该提到,我知道tomcat 7.0.15之前版本的“”。在此版本下,无法覆盖默认url映射。但正如我所说,我意识到了这一点,并使用了7.0.33版。所以这不可能是对的!?错了! 顺便说一句,我应该在jboss的404页面中注意到7.1.1(brontes)使用了7.0.13版或其他版本,而且永远不会工作。 但问题是什么呢。我使用了m2e wtp插件来构建我的应用程序。不幸的是,有一种东西打破了一切。首先,我认为它是嵌入式的,使用外部maven源代码确实解决了我的问题。也许版本不同?事实证明他们都使用3.0.4。奇怪的当我切换回嵌入式时,它工作了


摘要:使用webapplicationinitializer时,请使用Tomcat 7.0.15版本,最好使用外部maven源。

我解决了它!我应该提到,我知道tomcat 7.0.15之前版本的“”。在此版本下,无法覆盖默认url映射。但正如我所说,我意识到了这一点,并使用了7.0.33版。所以这不可能是对的!?错了! 顺便说一句,我应该在jboss的404页面中注意到7.1.1(brontes)使用了7.0.13版或其他版本,而且永远不会工作。 但问题是什么呢。我使用了m2e wtp插件来构建我的应用程序。不幸的是,有一种东西打破了一切。首先,我认为它是嵌入式的,使用外部maven源代码确实解决了我的问题。也许版本不同?事实证明他们都使用3.0.4。奇怪的当我切换回嵌入式时,它工作了

摘要:使用webapplicationinitializer时,请使用Tomcat 7.0.15版本,最好使用外部maven源代码

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>hello</groupId>
<artifactId>hello</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
  <plugins>
    <plugin>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>2.3.2</version>
      <configuration>
        <source>1.6</source>
        <target>1.6</target>
      </configuration>
    </plugin>
    <plugin>
      <artifactId>maven-war-plugin</artifactId>
      <version>2.3</version>
      <configuration>
        <failOnMissingWebXml>false</failOnMissingWebXml>
      </configuration>
    </plugin>
  </plugins>
</build>
<properties>
    <project.build.sourceEncoding>utf8</project.build.sourceEncoding>
</properties>
<dependencies>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.1.8.Final</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>3.1.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>3.1.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
    <groupId>javax.inject</groupId>
    <artifactId>javax.inject</artifactId>
    <version>1</version>
</dependency>
<dependency>
    <groupId>cglib</groupId>
    <artifactId>cglib</artifactId>
    <version>2.2.2</version>
</dependency>
 </dependencies>
 </project>