启嘟渡科技商贸有限公司
SEARCH

与我们合作

我们专注提供互联网一站式服务,助力企业品牌宣传多平台多途径导流量。
主营业务:网站建设、移动端微信小程序开发、营销推广、基础网络、品牌形象策划等

您也可通过下列途径与我们取得联系:

微 信: wxyunyingzhe

手 机: 15624122141

邮 箱:

spring boot网页录制音频后存储到数据库

更新时间:2025-01-22 19:04:50

1.从前端获取数据,同时存储到use当中
public String login(HttpServletRequest request) {
User user = new User();
user.setPhone(request.getParameter("telephone"));
user.setName(request.getParameter("username"));
user.setPassword(request.getParameter("password"));
user.setEmail(request.getParameter("email"));
implementChat.saveUser(user);
System.out.println("LOGIN success");
return "login";
}
2.定义user类,其中@Column(name = "telephone", length = 50),"telephone代表列的名字
import javax.persistence.*;
@Entity
@Table(name = "user")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Column(name = "telephone", length = 50)
private String telephone;
@Column(name = "username", length = 50)
private String username;
@Column(name = "password", length = 50)
private String password;
@Column(name = "email", length = 50)
private String email;

3.service层
@Service
@Transactional
public class UserService {
@Autowired
private ChatRespositroy chatRepository;
public void saveUser(User user) {
chatRepository.save(user);
}

4.repostroy层
@Repository
public interface ChatRespositroy extends CrudRepository {
User findUserById(int id);
List findUserByTelephone(String phone);
List findUserByUsername(String name);
User findUserByPassword(String password);
User findUserByEmail(String email);

多重随机标签

猜你喜欢文章

QQ客服 电话咨询