67,540
社区成员
发帖
与我相关
我的任务
分享
我要的结果死活出不来!
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd http://xmlns.jcp.org/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.4">
<!--configure the setting of springmvcDispatcherServlet and configure the mapping-->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:HelloWeb-servlet.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>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.test" />
<!-- configure the InternalResourceViewResolver -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
id="internalResourceViewResolver">
<!-- 前缀 -->
<property name="prefix" value="/WEB-INF/" />
<!-- 后缀 -->
<property name="suffix" value=".jsp" />
</bean>
</beans>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
出来吧!message: ${message}
</body>
</html>
package com.test;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
@RequestMapping("/hello")
public class HelloController {
@RequestMapping(method = RequestMethod.GET)
public String printHello(ModelMap model){
System.out.println("求打印!!!!!!");
model.addAttribute("message", "Hello SpringMVC !!");
return "hello";
}
}

[/quote]
我快要崩溃了,还是不行!加了那两个mvn[/quote]
看你纠结成这样,为了拯救你,老夫特地扒出了尘封已久的SpringMVC教程攻读。。
然而,最终,结果,我却发现,两个问题:
第一,你的xml文件位置不对,web.xml要放在WEB-INF目录下,HelloWeb-servlet.xml要放在src目录下,如下图所示:
第二,你的spring.jar是哪来的????
而且版本也不对,赶紧删了。。
然后:
不知道你是不是想要这个输出
[/quote]
大神好厉害!
[/quote]
我快要崩溃了,还是不行!加了那两个mvn[/quote]



[/quote]
我快要崩溃了,还是不行!加了那两个mvn[/quote]
web.xml放在WEB-INF下面,HelloWeb-servlet.xml.放在src下面就可以了
[/quote]
我快要崩溃了,还是不行!加了那两个mvn
[/quote]
这不是显示出来了嘛
?[/quote]
这是直接访问页面的结果,并没有我从后台取出数据,后台的程序打印也没有输出。
[/quote]
这不是显示出来了嘛
?
还是不行。。。。
我上传了,帮我看看,入门都入不了,好心痛http://pan.baidu.com/s/1hsJtd5a