Spring mvcアプリケーションを実装してJBossにデプロイし、ブラウザから呼び出せるようにしようとしています。Spring MVCのフルコードリクエストマッピングが見つかりません
私のWebConfig:
package com.heatmanofurioso.concertlivecheck.webapp;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;
public class WebConfig implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
//Defining web xml
AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(SpringApplicationConfig.class);
rootContext.setServletContext(servletContext);
//Registering servlet
ServletRegistration.Dynamic dispatcher = servletContext.addServlet("DispatcherServlet", new DispatcherServlet(rootContext));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
servletContext.addListener(new ContextLoaderListener(rootContext));
}
}
のjboss-web.xmlの
<?xml version="1.0" encoding="UTF-8" ?>
<jboss-web>
<context-root>CLC</context-root>
</jboss-web>
ログインコントローラ
package com.heatmanofurioso.concertlivecheck.plugin.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class LoginController {
@RequestMapping(value = "/test", method = RequestMethod.GET)
public String greeting5(@RequestParam(value = "name", defaultValue = "World1") String name) {
return "Test" + name;
}
}
SpringApplicationConfig
package com.heatmanofurioso.concertlivecheck.webapp;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@EnableWebMvc
@Configuration
@ComponentScan(basePackages = {
"com.heatmanofurioso.concertlivecheck",
"com.heatmanofurioso.concertlivecheck.plugin"})
public class SpringApplicationConfig extends WebMvcConfigurerAdapter {
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
}
私の春のバージョンが最新の4.xリリースであり、すべては私のメインのポンポンで宣言 私のwebappポンポン
<?xml version="1.0" encoding="UTF-8"?>
<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>
<packaging>war</packaging>
<artifactId>webapp</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>com.heatmanofurioso.concertlivecheck</groupId>
<artifactId>ConcertLiveCheck</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<!--Project modules-->
<dependency>
<groupId>com.heatmanofurioso.concertlivecheck</groupId>
<artifactId>utils</artifactId>
</dependency>
<dependency>
<groupId>com.heatmanofurioso.concertlivecheck</groupId>
<artifactId>database</artifactId>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.heatmanofurioso.concertlivecheck</groupId>
<artifactId>service</artifactId>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.heatmanofurioso.concertlivecheck</groupId>
<artifactId>plugin</artifactId>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warName>${parent.artifactId}</warName>
<outputDirectory>${project.build.directory}/../../../../../deployments/</outputDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>install</id>
<phase>install</phase>
<goals>
<goal>sources</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<properties>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>
</project>
私は、例のJSPファイルを持って、どの私はマップされたルートを入力しようとするときはlocalhostと同様に、8080/CLC :しかし、私のブラウザが見つけ、ローカルホストで読むことができます8080/CLC /テストを 私は404
ルートかもしれないもの上の任意のヒントを得ます私の問題に?
、それが関連するのですが、春バージョンは4.3.10リリースで、JBossが乱暴
アップデートであることを確認していない場合:だから 、私は4.3.7リリースに春のバージョンをダウングレードし、すべてが今、何のアイデアで働いているのですか?私はまた、Mavenをダウングレードする前に、同じ春バージョンですべての単一のコンポーネントをバンドルしていることを認定
うまく働い:dispatcher.addMapping(「/ *」を)。 Dispatcherサーブレットがすべてのリクエストを処理するようにします。 –
'localhost:8080/CLC/test?name = test'はどうですか? – StanislavL
@StanislavLパラメータは、送信されるリクエスト自体とは何の関係もなく、変数はnullになります。または私は間違っていますか?とにかく、ありがとう、私はそれを試してみました。しかし、いいえ:( –