关于方法级别的@ControllerAdvice

时间:2017-02-27 02:42:00

标签: java spring spring-mvc controller

我的spring mvc项目中有两个ControllerAdvices。

browser = webdriver.Chrome()
browser.set_window_position(0, 0)
browser.set_window_size(0, 0)

现在,我在@Controller注释类中有一些@ResponseBody注释方法。是否有方法级别的注释,然后我可以在我的AdviceController中为@ResponseBody注释方法编写该方法。

//return the json message
@ControllerAdvice(annotations = RestController.class) 
public class AdviceRestController

//redirect to the error
@ControllerAdvice(annotations = Controller.class) 
public class AdviceController

1 个答案:

答案 0 :(得分:0)

取决于你想做什么。您可以实现一个System.out.println("Enter Second Side: "); //move this inside below loop if you want to prompt user for each invalid input. while(true) { if (sc.hasNextDouble()) { secondside = sc.nextDouble(); break; //if we get double value, then break this loop; } else { sc.nextLine(); continue; //you can remove this continue } } 带注释的类来实现ControllerAdvice

ResponseBodyAdvice<T>