【发布时间】:2019-03-26 13:57:16
【问题描述】:
我正在尝试使用Spring + JSF 构建一个基本网页。
基本上,我有一个HelloController 和HelloSpringService。
它在HelloController 类中返回helloSpringService.sayHello(); 行时出错。
public class HelloController {
@ManagedProperty("#{helloSpringService)")
private HelloSpringService helloSpringService;
public String showHello() {
return helloSpringService.sayHello();
}
public void setHelloSpringService(HelloSpringService helloSpringService) {
this.helloSpringService = helloSpringService;
}
public HelloSpringService getHelloSpringService() {
return helloSpringService;
}
}
import org.springframework.stereotype.Service;
@Service
public class HelloSpringService {
public String sayHello() {
return "hellofromspringservice";
}
}
【问题讨论】:
-
请检查我上面评论的 SO 帖子中的答案。