问答详情
源自:3-5 Hello Spring MVC

http://localhost:8080/hello/mvc 报404错误

C:\workspacej2ee\weishop>mvn jetty:run

[INFO] Scanning for projects...

[INFO]

[INFO] ------------------------------------------------------------------------

[INFO] Building weishop Maven Webapp 1.0-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[INFO]

[INFO] >>> jetty-maven-plugin:9.2.2.v20140723:run (default-cli) > test-compile @ weishop >>>

[INFO]

[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ weishop ---

[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!

[INFO] Copying 0 resource

[INFO]

[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ weishop ---

[INFO] Nothing to compile - all classes are up to date

[INFO]

[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ weishop ---

[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!

[INFO] skip non existing resourceDirectory C:\workspacej2ee\weishop\src\test\resources

[INFO]

[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ weishop ---

[INFO] Nothing to compile - all classes are up to date

[INFO]

[INFO] <<< jetty-maven-plugin:9.2.2.v20140723:run (default-cli) < test-compile @ weishop <<<

[INFO]

[INFO] --- jetty-maven-plugin:9.2.2.v20140723:run (default-cli) @ weishop ---

[INFO] Logging initialized @3515ms

[INFO] Configuring Jetty for project: weishop Maven Webapp

[INFO] webAppSourceDirectory not set. Trying src\main\webapp

[INFO] Reload Mechanic: automatic

[INFO] Classes = C:\workspacej2ee\weishop\target\classes

[INFO] Context path = /

[INFO] Tmp directory = C:\workspacej2ee\weishop\target\tmp

[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml

[INFO] Web overrides =  none

[INFO] web.xml file = file:/C:/workspacej2ee/weishop/src/main/webapp/WEB-INF/web.xml

[INFO] Webapp directory = C:\workspacej2ee\weishop\src\main\webapp

[INFO] jetty-9.2.2.v20140723

[INFO] No Spring WebApplicationInitializer types detected on classpath

[INFO] Initializing Spring root WebApplicationContext

log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).

log4j:WARN Please initialize the log4j system properly.

log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

[INFO] Initializing Spring FrameworkServlet 'mvc-dispatcher'

[INFO] Started o.e.j.m.p.JettyWebAppContext@79a1728c{/,file:/C:/workspacej2ee/weishop/src/main/webapp/,AVAILABLE}{file:/C:/workspacej2ee/weishop/src/main/webapp/}

[WARNING] !RequestLog

[INFO] Started ServerConnector@1a015bc0{HTTP/1.1}{0.0.0.0:8080}

[INFO] Started @7351ms

[INFO] Started Jetty Server


提问者:Ahu342718 2016-09-05 21:24

个回答

  • wat1r3461256
    2017-09-25 20:10:41

    是可以的:(tomcat做server时,要加上项目名称):

    http://localhost:8080/spring-mvc-study/hello/mvc  运行后报503错误,发现没有导入jstl的jar包,导入pom的坐标:

    <dependency> 

    <groupId>javax.servlet</groupId> 

    <artifactId>jstl</artifactId> 

    <version>1.2</version> 

    </dependency>

    完成:

    http://img4.mukewang.com/59c8f23c0001af4104360135.jpg

  • botao555
    2017-05-11 00:22:13

    大哥,你的问题解决了吗,我跟你一样的问题,我用的tomcat运行的,访问http://localhost:8080/ZLearnSpringMvc/hello/mvc就报错,ZLearnSpringMvc是我的项目名,求解答啊。。

    http://img.mukewang.com/59133def0001cfe816520368.jpg

  • 就是要战逗
    2016-11-21 17:19:30

    这个问题我已经完全解决了,之间还遇到许多问题。

    听我说可能的原因,首先这个 jetty的启动没什么问题,它已经启动了,然后由于是jetty做的web容器,所以你访问的应该是  http://localhost:8080/hello/mvc , 但是出现报错,看不出原因,因此我建议把jetty停掉,改为tomcat启动(用tomcat可以快速定位原因),此时先看它控制台有没有异常输出,然后tomcat 访问地址应该是: http://localhost:8080/你的项目名/hello/mvc  ,再看 异常输出,之后就是对这些异常依个排除就行了。

    等到tomcat可以正常访问,那换成jetty也可以访问了。


    ps:顺便说一下我遇到的问题,

    第一个问题是  java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet 。。。

       解决方法:**工程名上右击 -> Properties -> Deployment Assembly,
    Add -> Java Build Path Entries -> next -> 选择maven Dependencies**


    第二个问题是 jstl not found 

    解决方法:在pom.xml里 加入:

    <dependency> 

    <groupId>javax.servlet</groupId> 

    <artifactId>jstl</artifactId> 

    <version>1.2</version> 

    </dependency>



  • 慕粉4218771
    2016-10-29 13:41:43

    http://localhost:8080/spring-mvc-study/hello/mvc这个也不行

  • jayson118
    2016-09-06 11:28:58

    我不知道老师是怎么运行出来的,我用的myeclipse中的tomcat,应该输入http://localhost:8080/项目名/hello/mvc,才能正常显示

  • ForSum
    2016-09-05 22:50:37

    你的项目名叫weishop吧,你访问

    http://localhost:8080/weishop/mvc才可以吧