jsf - 当我连接到工作台时,jsf 设置错误
问题描述
我是 java ee 的新手,我正在尝试使用 java ee 创建我的第一个网站,但是当我想将我的 jsf 连接到工作台时我发现很多困难我也有序列化问题,因为我总是生成手动 bean 序列
这是我的豆子 Userbean.java
@ManagedBean
@Named /*("userBean")*/
@RequestScoped
public class Userbean implements Serializable{
private static final long serialVersionUID = 1043069413653729199L;
private String iduser="";
private String username="name";
private String password="0000";
private String email="";
private String city="";
private String country="";
public Userbean() {
super();
// TODO Auto-generated constructor stub
}
public Userbean(String iduser, String username, String password, String email, String city, String country) {
super();
this.iduser = iduser;
this.username = username;
this.password = password;
this.email = email;
this.city = city;
this.country = country;
}
public String getIduser() {
return iduser;
}
public void setIduser(String iduser) {
this.iduser = iduser;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String returnAction2() {
PreparedStatement ps;
String query ="INSERT INTO `jee`.`user`( `username`, `email`, `password`, `city`, `country`) VALUES (?,?,?,?,?)";
boolean a=false;
try {
ps= Myconnection.getConnection().prepareStatement(query);
ps.setString(1,username);
ps.setString(2,email);
ps.setString(3,password);
ps.setString(4,city);
ps.setString(5,country);
if(ps.executeUpdate()>0){
a=true;
}
} catch (SQLException ex) {
ex.getStackTrace();
a=false;
}
return a==true ? "success" : "failure";
}
}
这是我的观点注册
<!DOCTYPE html>
<html xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<f:view>
<head>
<title>Login screen</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body>
<h1>sign up</h1>
<h:form>
username:
<h:inputText id="username" value="#{userBean.username}" />
<br/>
Password:
<h:inputSecret id="password1" value="#{userBean.password}" />
<br/>
email:
<h:inputSecret id="email" value="#{userBean.email}" />
<br/>
city:
<h:inputSecret id="city" value="#{userBean.city}" />
<br/>
country:
<h:inputSecret id="country" value="#{userBean.country}" />
<br/>
<h:commandButton action="#{userBean.returnAction2}" value="Connect" />
</h:form>
</body>
</f:view>
</html>
解决方案
推荐阅读
- php - 我在用 php 和 mysqli 解密时遇到问题
- python - 使用贝叶斯优化绘制 xgboost 评估指标
- javascript - 在移动到另一个进程之前如何解决异步进程?
- python - 我将如何检索实时网站数据并将其打印到 python GUI 中的文本小部件
- r - 为 rollapply 窗口应用循环
- mysql - 为什么没有聚合函数的选择列需要成为 MySQL 中 Group by 子句的一部分?
- android - RxJava 如何在链中的不同点以不同方式处理错误
- java - NotSerializableException:java.io.FileInputStream
- linux - GIT 上传 - Linux 用户名显示而不是 git 用户名
- javascript - 自动滚动 fullcalendar V5(resourceTimelineWeek View) 到当前日期和时间