注册 登录
编程论坛 J2EE论坛

springmvc-404-异常

翰海蓝纲 发布于 2019-08-29 17:04, 5085 次点击
用IDEA做springmvc的入门程序,看着代码都没问题,Tomcat启动也成功了,可是就是跳不到页面
老是报404-The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
有没有大神帮忙看看问题在哪呀,Please!

ItemsController.class
程序代码:
@Controller
public class ItemsController{

    @RequestMapping("/hello")
    public String hello(){
        return "success";
    }
}

springmvc.xml
程序代码:
<context:component-scan base-package="cn.hzg.controller"/>

    <bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/"/>
        <property name="suffix" value=".jsp"/>
    </bean>

    <mvc:annotation-driven/>

web.xml
程序代码:
<servlet>
        <servlet-name>dispatcherServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:springmvc.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcherServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

index.jsp
程序代码:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>$Title$</title>
  </head>
  <body>
  <a href="hello">入门</a>
  </body>
</html>


[此贴子已经被作者于2019-8-30 10:13编辑过]

0 回复
1