一个 Controller 对应一个 URL,由请求参数决定请求处理方法
package com.baobaotao.web;
import com.baobaotao.service.BbtForumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/bbtForum.do") // <—— ① 指定控制器对应URL请求
public class BbtForumController {
@Autowired
private BbtForumService bbtForumService;
// <—— ② 如果URL请求中包括"method=listAllBoard"的参数,由本方法进行处理
@RequestMapping(params = "method=listAllBoard")
public String listAllBoard() {
bbtForumService.getAllBoard();
System.out.println("call listAllBoard method.");
return "listBoard";
}
// <—— ③ 如果URL请求中包括"method=listBoardTopic"的参数,由本方法进行处理
@RequestMapping(params = "method=listBoardTopic")
public String listBoardTopic(int topicId) {
//请求中的tipicId参数会自动给方法参数赋值
bbtForumService.getBoardTopics(topicId);
System.out.println("call listBoardTopic method.");
return "listTopic";
}
}
分享到:
相关推荐
spring注解 -----最简单的注解与自动装配例子
spring注解开发使用教程--Bean加载控制(二)案例代码
spring-demo10-注解-IOC.zip
spring-webmvc-struts.jar对Struts和Spring整合时需要用到的包
spring-cloud-microservice-in-action,spring cloud学习。
org.springframework.spring-library-3.0.4.RELEASE.libd org.springframework.test-3.0.4.RELEASE.jar org.springframework.transaction-3.0.4.RELEASE.jar org.springframework.web.portlet-3.0.4.RELEASE.jar ...
基于spring boot 的spring-boot-starter-hbase自动注解实现,HbaseTemplate的直接使用
基于注解的spring-security-login,有兴趣的朋友可以自己下来研究
Spring Security多身份验证展示柜基于Spring Boot的示例应用程序,展示了用于多个身份验证流程的案例Java配置-Siteminder...入门/运行应用程序克隆存储库,使用maven将其打包为jar,然后从目标文件夹运行jar git clone ...
org.springframework.spring-library-3.1.RELEASE.libd org.springframework.test-3.1.RELEASE.jar org.springframework.transaction-3.1.RELEASE.jar org.springframework.web.portlet-3.1.RELEASE.jar org....
下载下来就可以运行,注释清晰,Spring4 In Action-5.2.2-Spring Web应用程序-简单的控制器实现跳转
使用Spring的注解方式实现AOP的细节
注解包含: 拦截器 , 过滤器 , 序列化 , @After , @AfterReturning , @AfterThrowing , @annotation , @Around , @Aspect , @Autowired , @Bean , @Before , @Component , @ComponentScan , @ComponentScans , @...
这是对Spring中注解是怎么实现的一个大概基本原理,条件是采取的理想状态,所以代码中还有缺陷的话请谅解,如果有需要的朋友可以放心下载,里面有详细的解释和流程。相信你能看懂
spring-demo13-注解-@Value.zip
基于注解实现SpringAop基于注解实现SpringAop基于注解实现SpringAop
spring-boot-multi-mongodb:spring boot和mongodb多数据源的使用 spring-boot-package-war:spring-boot打包成war包示例 spring-boot-shiro:springboot 整合shiro rbac示例 spring-boot-file-upload:使用Spring ...
org.springframework.web-3.0.5.RELEASE.jar
Spring boot使用的各种示例,以最简单...spring-boot-multi-mongodb:spring boot和mongodb多数据源的使用 spring-boot-package-war:spring-boot打包成war包示例 spring-boot-shiro:springboot 整合shiro rbac示例
spring-context-3.2.4.RELEASE.jar spring-core-3.2.4.RELEASE.jar spring-beans-3.2.4.RELEASE.jar spring-test-3.2.4.RELEASE.jar spring-web-3.2.4.RELEASE.jar spring-aop-3.2.4.RELEASE.jar spring-webmvc-...