| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1647 人关注过本帖
标题:关于springMVC配置出错
只看楼主 加入收藏
hpd
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2018-4-23
收藏
 问题点数:0 回复次数:1 
关于springMVC配置出错
刚刚接触springmvc在配置的时候出错了,麻烦懂得朋友教教我,谢谢你们!



web.xml配置
 <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.
    xmlns="http://java.
    xsi:schemaLocation="http://java. http://java.
    id="WebApp_ID" version="3.0">
    <servlet>
        <servlet-name>springmvc</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/springmvc-config.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>springmvc</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>


springmvc-config.xml配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.
    xmlns:xsi="http://www. xmlns:mvc="http://www.
    xmlns:p="http://www. xmlns:context="http://www.
    xmlns:aop="http://www. xmlns:tx="http://www.
    xsi:schemaLocation="http://www.
            http://www.
            http://www.
            http://www.
            http://www.
            http://www.
            http://www.
            http://www.
            http://www.
            http://www.
            http://www.
            http://www.

    <bean name="/hello" class="org.fkit.controller.HelloController" />
     <bean
        class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
    <bean
        class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
    <bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver" />


</beans>

HelloController.ava配置

package org.fkit.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.
import org.
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

public class HelloController implements Controller {
    private static final Log logger = LogFactory.getLog(HelloController.class);

    @Override
    public ModelAndView handleRequest(HttpServletRequest arg0,
            HttpServletResponse arg1) throws Exception {
        logger.info("handleRequest被调用");
        ModelAndView mv = new ModelAndView();
        mv.addObject("message","Helloworld!");
        mv.setViewName("/WEB-INF/content/welcome.jsp");
        return mv;
    }

}

welcome.jsp配置
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>welcome</title>
</head>
<body>
    ${requestScope.message }
</body>
</html>

运行后eclipse自动跳转到http://localhost:8080/SpringMVCTest/WEB-INF/content/welcome.jsp

报404错误
搜索更多相关主题的帖子: 配置 xml http schema servlet 
2018-04-23 10:38
疯狂的小a
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:39
帖 子:423
专家分:1871
注 册:2018-2-6
收藏
得分:0 
http://localhost:8080/SpringMVCTest/hello
这是你的访问路径
结果
图片附件: 游客没有浏览图片的权限,请 登录注册

假如人生没有梦想,和咸鱼有什么区别!
2018-04-24 21:15
快速回复:关于springMVC配置出错
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.055983 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved