帮我把以下代码排版规整:1. // 通过主键删除数据 2. @RequestMapping("deleteCustomer.action") 3. public String deleteCustomer(String id) { 4. this.customerService.deleteCustomer(id); 5. return "redirect:/customer/getAllCustomer.action"; 6. } 7. // 批量删除数据 8. @RequestMapping("deleteCustomerByIds.action") 9. public String deleteCustomerByIds() { 10. String[] ids = this.getRequest().getParameterValues("customerid"); 11. for (String customerid : ids) { 12. this.customerService.deleteCustomer(customerid); 13. } 14. return "redirect:/customer/getAllCustomer.action"; 15. }
时间: 2024-02-26 09:52:22 浏览: 27
1. // 通过主键删除数据
2. @RequestMapping("deleteCustomer.action")
3. public String deleteCustomer(String id) {
4. this.customerService.deleteCustomer(id);
5. return "redirect:/customer/getAllCustomer.action";
6. }
7. // 批量删除数据
8. @RequestMapping("deleteCustomerByIds.action")
9. public String deleteCustomerByIds() {
10. String[] ids = this.getRequest().getParameterValues("customerid");
11. for (String customerid : ids) {
12. this.customerService.deleteCustomer(customerid);
13. }
14. return "redirect:/customer/getAllCustomer.action";
15. }
相关问题
1. // 通过主键删除数据 2. @RequestMapping("deleteCustomer.action") 3. public String deleteCustomer(String id) { 4. this.customerService.deleteCustomer(id); 5. return "redirect:/customer/getAllCustomer.action"; 6. } 7. // 批量删除数据 8. @RequestMapping("deleteCustomerByIds.action") 9. public String deleteCustomerByIds() { 10. String[] ids = this.getRequest().getParameterValues("customerid"); 11. for (String customerid : ids) { 12. this.customerService.deleteCustomer(customerid); 13. } 14. return "redirect:/customer/getAllCustomer.action"; 15. }
1. // 通过主键删除数据
2. @RequestMapping("deleteCustomer.action")
3. public String deleteCustomer(String id) {
4. this.customerService.deleteCustomer(id);
5. return "redirect:/customer/getAllCustomer.action";
6. }
7. // 批量删除数据
8. @RequestMapping("deleteCustomerByIds.action")
9. public String deleteCustomerByIds() {
10. String[] ids = this.getRequest().getParameterValues("customerid");
11. for (String customerid : ids) {
12. this.customerService.deleteCustomer(customerid);
13. }
14. return "redirect:/customer/getAllCustomer.action";
15. }
建springboot 工程 发送一个请求http:localhost:8080/hello 结果: 1. 我需要返回一个json 数据格式
好的,下面是建立Spring Boot工程以及实现返回JSON格式数据的步骤:
1. 使用Spring Initializr创建一个新的Spring Boot工程。在https://start.spring.io/页面上选择“Gradle Project”、“Java”、“Spring Boot 2.5.5”版本,并填写项目的Group、Artifact、Name、Package等信息,最后点击“Generate”按钮即可下载生成的工程文件。
2. 打开生成的工程文件,在src/main/java目录下创建一个名为“com.example.demo”的包,然后在该包下创建一个名为“HelloController”的类。该类需要使用Spring MVC注解来处理HTTP请求并返回JSON格式数据,代码如下:
```
package com.example.demo;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@RequestMapping("/hello")
public String hello() {
return "{\"message\": \"Hello, world!\"}";
}
}
```
在上面的代码中,@RestController注解表示该类处理HTTP请求并返回数据,@RequestMapping注解表示该方法处理“/hello”路径的请求,返回一个字符串类型的JSON格式数据。
3. 在终端中进入工程目录,使用Gradle命令启动工程:./gradlew bootRun。启动成功后,在浏览器中访问http://localhost:8080/hello,应该能够看到如下JSON格式的数据:
```
{"message": "Hello, world!"}
```
这就是返回JSON格式数据的实现方法。