2016-12-24 5 views
0

私のコードでは、jspで申し込みフォームを送信できません。サインアップ操作に介入するコードは次のとおりです。クラスjavax.el.BeanELResolverはjava.util.CollectionsクラスのメンバーにアクセスできませんSpring Boot、JSPのUnmodifiableCollection

User.java

@Entity 
@Table(name = "user", catalog = "spring_abc", uniqueConstraints = {@UniqueConstraint(columnNames = "email"), 
@UniqueConstraint(columnNames = "username")}) 
public class User implements java.io.Serializable { 

public static final String ROLE_ADMIN = "admin"; 
public static final String ROLE_MEMBER = "member"; 


private static final long serialVersionUID = 7376961072110620611L; 
private Integer id; 
private Long commentCount; 
private Date createAt; 
private String description; 
@Email(message = "Entrez le format de l'email correct") 
private String email; 

private long number; 

private String password; 

public void setDepartement(String departement) { 
    this.departement = departement; 
} 

private long points; 

private String role; 

@Size(max = 60, message = "Pas plus de soixante caractères") 
private String signature; 

private Long topicCount; 

@Size(max = 60, message = "Pas plus de soixante caractères") 
private String twitter; 

private Date updateAt; 

@Pattern(regexp = "^(?!_)(?!.*?_$)[A-Za-z0-9|_]{3,9}", message = "Nom d'utilisateur, ne peut pas commencer ou se terminer par un trait de soulignement") 
private String username; 

private Set<Follow> followsForFollowerId = new HashSet<Follow>(0); 
private Set<Notification> notifications = new HashSet<Notification>(0); 
private Set<Topic> topics = new HashSet<Topic>(0); 
private Set<Comment> comments = new HashSet<Comment>(0); 
private Set<Focus> focuses = new HashSet<Focus>(0); 
private Set<Collection> collections = new HashSet<Collection>(0); 
private Set<Follow> followsForFollowingId = new HashSet<Follow>(0); 
private Set<Comment> likeComments = new HashSet<Comment>(); 

Methodeのサービスパートのサインアップ。

@Transactional 
public User signup(User user, String password1, Errors errors) { 
    if (errors.hasErrors()) { 
     return null; 
    } 
    String username = user.getUsername(); 
    String password = user.getPassword(); 
    String email = user.getEmail(); 

    if (userRepo.findOneByUsername(username) != null) { 
     errors.rejectValue("username", "username", "Nom d'utilisateur déjà enregistré"); 
    } else if (userRepo.findOneByEmail(email) != null) { 
     errors.rejectValue("email", "email", "E-mail est déjà enregistré"); 
    } else if (!password.equals(password1)) { 
     errors.rejectValue("password", "password", "Les mots de passe ne se correspondent pas"); 
    } 
    if (errors.hasErrors()) { 
     return null; 
    } 

    user.setPassword(EncryptUtil.encryptUsernameAndPassword(username, password)); 

    user.setCreateAt(new Date()); 
    return userRepo.save(user); 
} 

コントローラAccount.java

@RequestMapping(value = "/signup", method = RequestMethod.POST) 
public String singupAction(@Validated User user, 
          Errors erros, 
          String password1, 
          RedirectAttributes attributese, 
          HttpServletRequest request) { 
    User signinUser = userServ.signup(user, password1, erros); 

    if (erros.hasErrors()) { 
     attributese.addFlashAttribute("user", user); 
     attributese.addFlashAttribute("error", erros.getAllErrors()); 
     return "redirect:/account/signup"; 
    } 


    request.getSession().setAttribute("user", signinUser); 
    attributese.addFlashAttribute("msg", "Vous êtes inscrit avec succès"); 

    return "redirect:/"; 
} 

Signup.jsp私は情報を検証しようとすると、問題が表示されます。

<form action="${x}/account/signup" data-toggle="validator" role="form" method="POST"> 
<input class="form-control" data-error="S'il vous plaît entrer une adresse email valide" placeholder="E-mail" type="email" id="email" name="email" value="${user.email}" /> 
<input class="form-control" id="username" data-error="Entre 6 et 18 caractères" pattern="^[_A-z0-9]{6,18}$" placeholder="Votre username" type="text" name="username" value="${user.username}" /> 
<input class="form-control" data-minlength="6" type="password" name="password" id="password" placeholder="Mot de passe" data-error="Entre 6 et 18 caractères" /> 
<input type="submit" class="btn btn-info btn-block" value="S'inscrire"> 

スタックは私には分かりません。それはあなたが各fieldのためにあなたのentitygetterssettersを追加する必要がある問題

org.apache.jasper.JasperException: javax.el.ELException: java.lang.IllegalAccessException: Class javax.el.BeanELResolver can not access a member of class java.util.Collections$UnmodifiableCollection with modifiers "public" 
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) 
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492) 
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378) 
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848) 
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684) 
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:501) 
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137) 

Caused by: javax.el.ELException: java.lang.IllegalAccessException: Class javax.el.BeanELResolver can not access a member of class java.util.Collections$UnmodifiableCollection with modifiers "public" 
at javax.el.BeanELResolver.invokeMethod(BeanELResolver.java:742) 
at javax.el.BeanELResolver.invoke(BeanELResolver.java:470) 
at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:257) 

答えて

0

を指摘していません。

私的長い番号。

entityに次のように定義する必要があります。あなたのスタックトレースから

public long getNumber(){ return this.number;} 
public void setNumber(long number){ this.number = number; } 

public getterメソッドとフィールドにアクセスしようとしていることは明らかであるが、それはそれはとてもスローされた例外を見つけることができませんでした。

+0

いいえ、私の友人はいません!私はエンティティコードをすべてコピーしませんでした!すべてのフィールドにセッターとゲッターがあります! –

関連する問題