开发者社区 问答 正文

Spring 路径报错

警告: No mapping found for HTTP request with URI [/] in DispatcherServlet with name 'appServlet'

@Controller
public class FirstController {
    /**
     * 网站首页
     * 
     * @return
     */
    @RequestMapping(value = "/",method =RequestMethod.GET)
    public String homePage() {
 
        return "index";
    }
     
    @RequestMapping(value = "/hello",method =RequestMethod.GET)
    @ResponseBody
    public String hello() {
        return "index";
    }
}
配置文件

<context:annotation-config />
    <mvc:annotation-driven />
    <context:component-scan base-package="com.whuboy.test" />
    <!-- Handles HTTP GET requests for /resources/** by efficiently serving 
        up static resources in the ${webappRoot}/resources/ directory -->
    <resources mapping="/resources/**" location="/resources/" />
    <!-- Resolves views selected for rendering by @Controllers to .jsp resources 
        in the /WEB-INF/views directory -->
    <beans:bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/view/" />
        <beans:property name="suffix" value=".jsp" />
    </beans:bean>

展开
收起
a123456678 2016-03-18 10:09:42 2285 分享
分享
版权
举报
1 条回答
写回答
取消 提交回答
  • 需要看看几个地方配置的相对地址路径是否正确

    2019-07-17 19:05:58 举报
    赞同 评论

    评论

    全部评论 (0)

    登录后可评论
问答分类:
问答标签:
问答地址: