我正在做一些有关Spring Framework和Primefaces的示例,但是我的按钮没有调用视图层中的简单printf函数。如何调用我的函数并在控制台上打印一些字符串?
这是我的xhtml部分:
<h:form id="jobForm">
<p:commandButton id="Print" value="Submit"
actionListener="#{jobView.myFunc}" />
</h:form>
这是我的JobView.java文件:
import javax.annotation.PostConstruct;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.myjob.model.JobModel;
import com.myjob.utility.Utility;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Component(value = "jobView")
@Scope(value = "view")
public class JobView implements Serializable {
private static final long serialVersionUID = 6901036085773777713L;
private List<JobModel> jobs;
private HashMap<String, String> cbLevels;
private HashMap<String, String> selectedLevels;
private String selectedLevel;
public void startDataTable() {
jobs = Utility.getResponse("http://localhost:8080/jobs/all");
cbLevels = new HashMap<String, String>();
//Filling hashmap here.
cbLevels.put("Working", "Working");
cbLevels.put("Graduated", "Graduated");
cbLevels.put("Student", "Student");
}
@PostConstruct
public void init() {
startDataTable();
}
//My print function which i want to call
public String myFunc(){
System.out.println("Hello !");
return "";
}
}
答案 0 :(得分:0)
我的问题是因为pom.xml中的Spring Security依赖性。我删除并解决了。