急需理解Spring3.0 MVC的原理 本帖最后由 wdarren 于 2011-03-11 10:57:27 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 spring mvc : http://static.springsource.org/spring/docs/2.0.x/reference/mvc.html 官方在线文档,不要太爽哦 <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> <!-- Configures support for @Controllers --> <mvc:annotation-driven /> <!-- Resolves view names to protected .jsp resources within the /WEB-INF/views directory --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/"/> <property name="suffix" value=".jsp"/> </bean> </beans>import org.slf4j.Logger;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;@Controller@RequestMapping("/Hello")public class HelloController { private Logger logger = org.slf4j.LoggerFactory.getLogger(HelloController.class); @RequestMapping(method=RequestMethod.GET) public void Hello(){ logger.info("Hello Controller is run "); } }sprint3.0以后是通过注解来实现requestmapping的,如上所示,意思就是你访问/Hello这个url,就会映射到/WEB-INF/views/下的Hello.jsp你上面的方法倒是想2.0版本的,指定xxx.do,去找某个c,然后c里面return到指定的jsp。 看下源码结构,然后用Xmind写个思维导图。。 你说的是视图如何返回的了,我一个请求,它可能会被一些业务逻辑来处理,那么是谁来控制这个请求去找到它对应的业务逻辑里面去的(也就是所谓的Model)?<context:annotation-config/>这个标签是用来做什么的? 跪求 struts2完全学习手册源码 使用Ext后,访问速度大幅降低 java高手求SHELL 【怒了】我不信这个webwork入门级的问题,诺大个CSDN论坛都没人能解决!谁要是帮我解决了,我把所有积分都给他!! 问一个hibernate连接查询的问题 spring security3 session过期,拦截异步请求返回登陆页面 安装j2ee1.4遇到的问题 tomcat配置文件的一个疑惑 怎么安装struts 谁有关于ejb方面的书或者资料推荐??一定给分 关于一个小算法的问题. java截取字符串
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> <!-- Configures support for @Controllers -->
<mvc:annotation-driven /> <!-- Resolves view names to protected .jsp resources within the /WEB-INF/views directory -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
import org.slf4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;@Controller
@RequestMapping("/Hello")
public class HelloController {
private Logger logger = org.slf4j.LoggerFactory.getLogger(HelloController.class);
@RequestMapping(method=RequestMethod.GET)
public void Hello(){
logger.info("Hello Controller is run ");
}
}
sprint3.0以后是通过注解来实现requestmapping的,如上所示,意思就是你访问/Hello这个url,就会映射到/WEB-INF/views/下的Hello.jsp你上面的方法倒是想2.0版本的,指定xxx.do,去找某个c,然后c里面return到指定的jsp。
<context:annotation-config/>这个标签是用来做什么的?