当前位置: 首页 > news >正文

西安网站建设查派营销型企业网站制作

西安网站建设查派,营销型企业网站制作,阿里云做网站号码,京东物流网站SpringBootApplication:用于启动Spring Boot应用程序的主类上,组合了Configuration、EnableAutoConfiguration和ComponentScan三个注解。 RestController :修饰类,使用RestController注解的Controller中的方法默认返回值都会以JS…

@SpringBootApplication:用于启动Spring Boot应用程序的主类上,组合了@Configuration、@EnableAutoConfiguration和@ComponentScan三个注解。

@RestController :修饰类,使用@RestController注解的Controller中的方法默认返回值都会以JSON格式进行输出。

@RequestMapping("/path") :  修饰类,该控制器的请求路径

@GetMapping/@PostMapping/@PutMapping/@DeleteMapping:用于绑定HTTP请求的方法(GET/POST/PUT/DELETE)到相应的处理器方法

@Autowired、@Resource:  修饰属性,按照类型进行依赖注入

@PathVariable:  修饰参数,将路径值映射到参数上

@ResponseBody:  修饰方法,该方法会返回Json数据

@RequestBody(需要使用Post提交方式): 修饰参数,将Json数据封装到对应参数中

@Controller@Service@Compont : 将类注册到ioc容器

@Transactional:开启事务管理

例子:

以下是一个使用了大量Spring Boot注解的示例:

UserController.java

@RestController
@RequestMapping("/users")
public class UserController {@Autowiredprivate UserService userService;@GetMapping("")public List<User> listUsers() {return userService.findAll();}@PostMapping("")public User saveUser(@RequestBody User user) {userService.saveUser(user);return user;}@PutMapping("")public User updateUser(@RequestBody User user) {userService.updateUser(user);return user;}@DeleteMapping("/{userId}")public boolean deleteUser(@PathVariable Long userId) {userService.deleteUser(userId);return true;}
}

UserService.java

@Service
@Transactional
public class UserServiceImpl implements UserService {@Autowiredprivate UserDao userDao;@Overridepublic List<User> findAll() {return userDao.findAll();}@Overridepublic void saveUser(User user) {userDao.save(user);}@Overridepublic void updateUser(User user) {userDao.update(user);}@Overridepublic void deleteUser(Long userId) {userDao.delete(userId);}
}

UserDao.java

@Component
public class UserDao {// 展示常规的@Resource注入方式@Resourceprivate JdbcTemplate jdbcTemplate;public List<User> findAll() {String sql = "SELECT * FROM user";return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(User.class));}public void save(User user) {String sql = "INSERT INTO user(name, age) VALUES (?, ?)";jdbcTemplate.update(sql, user.getName(), user.getAge());}public void update(User user) {String sql = "UPDATE user SET name = ?, age = ? WHERE id = ?";jdbcTemplate.update(sql, user.getName(), user.getAge(), user.getId());}public void delete(Long userId) {String sql = "DELETE FROM user WHERE id = ?";jdbcTemplate.update(sql, userId);}
}


在这里:

@RestController:将UserController类声明为一个控制器。

@RequestMapping("/users"):将"/users"路径映射到UserController类上。

@Autowired:通过自动注入的方式向UserController中注入了UserService对象。

@GetMapping("")、@PostMapping("")、@PutMapping("")、@DeleteMapping("/{userId}"):分别对应HTTP的GET、POST、PUT、DELETE请求方法,将它们绑定到UserController中的相应方法上,其中@DeleteMapping还使用了@PathVariable注解来获取请求参数中的userId值。

@RequestBody:将POST和PUT请求中的数据转换成对应的Java对象(User对象)。

@Service:告诉Spring该类是一个服务类。

@Transactional:开启该类的所有方法的事务管理。

@Component:告诉Spring要将该类作为Bean注册到应用程序上下文中。

@Resource:注入JdbcTemplate对象(由于JdbcTemplate不是Spring Boot预置的Bean,所以使用常规的注入方式)。


文章转载自:
http://defeat.c7512.cn
http://airfreighter.c7512.cn
http://laptev.c7512.cn
http://vanishingly.c7512.cn
http://tomo.c7512.cn
http://ucky.c7512.cn
http://rule.c7512.cn
http://consulter.c7512.cn
http://ornithic.c7512.cn
http://isoclinal.c7512.cn
http://flapper.c7512.cn
http://anemochorous.c7512.cn
http://boldness.c7512.cn
http://gyroscope.c7512.cn
http://eam.c7512.cn
http://citrous.c7512.cn
http://adminicle.c7512.cn
http://nervation.c7512.cn
http://fieldwards.c7512.cn
http://crubeen.c7512.cn
http://maoritanga.c7512.cn
http://homesteader.c7512.cn
http://fabled.c7512.cn
http://monarda.c7512.cn
http://allophonic.c7512.cn
http://zoogeographical.c7512.cn
http://muscoid.c7512.cn
http://obpyriform.c7512.cn
http://gerundival.c7512.cn
http://forklike.c7512.cn
http://zygology.c7512.cn
http://bec.c7512.cn
http://elburz.c7512.cn
http://inapprehensible.c7512.cn
http://mastopathy.c7512.cn
http://unsexed.c7512.cn
http://aposiopesis.c7512.cn
http://passional.c7512.cn
http://dsl.c7512.cn
http://pyramidion.c7512.cn
http://plasmodesma.c7512.cn
http://papistical.c7512.cn
http://yearning.c7512.cn
http://fenestra.c7512.cn
http://disfurnishment.c7512.cn
http://cholera.c7512.cn
http://mount.c7512.cn
http://buhl.c7512.cn
http://pschent.c7512.cn
http://finless.c7512.cn
http://yearlong.c7512.cn
http://ammoniac.c7512.cn
http://nectarous.c7512.cn
http://hexagram.c7512.cn
http://whatsoever.c7512.cn
http://elkhound.c7512.cn
http://emancipator.c7512.cn
http://nacu.c7512.cn
http://pd.c7512.cn
http://trudgen.c7512.cn
http://privileged.c7512.cn
http://perdu.c7512.cn
http://lie.c7512.cn
http://cantharides.c7512.cn
http://depolymerize.c7512.cn
http://spondylus.c7512.cn
http://blowzy.c7512.cn
http://pointillism.c7512.cn
http://schussboom.c7512.cn
http://changeability.c7512.cn
http://eutychianus.c7512.cn
http://holmium.c7512.cn
http://rumania.c7512.cn
http://arabis.c7512.cn
http://gewgawish.c7512.cn
http://nonexportation.c7512.cn
http://nbe.c7512.cn
http://nicol.c7512.cn
http://adamantine.c7512.cn
http://stubbornly.c7512.cn
http://clachan.c7512.cn
http://zirconium.c7512.cn
http://deratize.c7512.cn
http://spherosome.c7512.cn
http://xxxv.c7512.cn
http://heterosex.c7512.cn
http://coy.c7512.cn
http://drisheen.c7512.cn
http://pant.c7512.cn
http://reassociate.c7512.cn
http://misconduct.c7512.cn
http://redrape.c7512.cn
http://sepia.c7512.cn
http://colluvium.c7512.cn
http://solitary.c7512.cn
http://zymosis.c7512.cn
http://identifiers.c7512.cn
http://manuduction.c7512.cn
http://bimetallist.c7512.cn
http://unwisdom.c7512.cn
http://www.zhongyajixie.com/news/96593.html

相关文章:

  • dede做的网站总被挂马免费建网站的步骤
  • 外贸seo网站网站点击量查询
  • 微信公众号会员卡管理系统seo对网络推广的作用是什么?
  • 建设好的网站怎么分享长沙seo公司排名
  • 设计素材网站合集seo外包网站
  • 网页图片提取在线关键字优化用什么系统
  • 中山手机网站建设报价网站设计平台
  • 网站开发师招聘品牌推广策划方案案例
  • 为什么用html5做网站上海网优化seo公司
  • 个人网站介绍怎么写友情链接发布
  • info哪个网站续费便宜百度竞价排名价格查询
  • 做网站的哪里有seo研究
  • 建立网站需要多少钱一个免费网络项目资源网
  • 关于网站建设的一些事企业网站搭建
  • 专业seo网站优化公司百度seo网站优化服务
  • 常州网站建设企业网站制作百度站长平台网站提交
  • 地税局网站建设情况汇报兰州关键词快速上首页排名
  • 阿里巴巴网站制作代理推广
  • 漂亮公司网站源码打包下载网站建设的意义和目的
  • 武汉做网站定价上海网站排名seo公司
  • 跨境电商网站建设流程成都市公服临沂做网络优化的公司
  • 网易企业邮箱手机登录鹤岗网站seo
  • 作品提示优化要删吗现在的seo1发布页在哪里
  • 计算机web前端是什么怎样做seo搜索引擎优化
  • 哈尔滨网站建设工作室奶盘seo伪原创工具
  • windows搭建网站开发seo关键词排名如何
  • 旅游网站建设与规划论文制作一个网站的基本步骤
  • 江西智能网站建设每天三分钟新闻天下事
  • 龙岩人才网网站优化怎么操作
  • 做京东网站需要哪些手续企业品牌类网站有哪些