1
я пишу простую форму, чтобы принять имя и фамилиюStruts2 JavaBeans и сеттер
это мой index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Form di inserimento</title>
</head>
<body>
<h1>Inserisci il tuo nome e il tuo cognome</h1>
<s:form action="Form">
<s:textfield name="nome" label="il tuo nome"/>
<s:textfield name="cognome" label="il tuo cognome"/>
<s:submit/>
</s:form>
</body>
</html>
это мой ResultForm.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Risultato della form</title>
</head>
<body>
<h1><s:property value="customPage"/></h1>
</body>
</html>
и это мой класс действия
package com.paolo;
import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
public class Form extends ActionSupport {
private static final String GREETINGS = "Congratulazioni ";
private String nome;
private String cognome;
private String customPage;
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getCognome() {
return cognome;
}
public void SetCognome(String cognome) {
this.cognome = cognome;
}
public String getCustomPage() {
return customPage;
}
public void setCustomPage(String customPage) {
this.customPage = customPage;
}
public String execute() {
setCustomPage(GREETINGS + " " + getNome() + " " + getCognome());
return SUCCESS;
}
}
это все нормально, но Cognome (= фамилия) является наборами для нуля, когда я иду в ResultForm.jsp спасибо за помощь
ой спасибо я не улавливаю имя было неправильно жаль – user3180807