我在这里遇到过很多问题,但并没有解决我的问题。我有一个HTML表单,我想在单击提交按钮时调用托管bean类的方法。这是代码。
HTML表单:
<form class="form-horizontal" action= "" method="post">
<div class="control-group">
<label class="control-label" for="inputEmail">Username</label>
<div class="controls">
<input type="text" id="inputUsrname" name="usrname" placeholder="Username" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputEmail">Email</label>
<div class="controls">
<input type="text" id="inputUsrname" name="email" placeholder="Email"/>
</div>
</div>
<button class="btn btn-primary" type="submit">Submit</button>
<h:commandButton value="click" action="#{hello_World.getMessage()}"/>
<button class="btn" type="reset">Reset</button>
</form>
Managed Bean类:
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
@ManagedBean(name="hello_World", eager=true)
public class HelloWorld {
public HelloWorld() {
System.out.println("Helloworld started from managed bean");
}
public String getMessage() {
System.out.println("sjdfksadfbasdjkfh");
return "indexx.xhtml";
}
}
单击单击按钮时,没有任何反应。 谢谢。