主页
<%@ page contentType="text/html; charset=GB2312" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>登陆成功</title>
</head><body>
<s:form action="Chengxu1.action" method="post">
<s:textfield name="username" label="用户名"/>
<s:password name="password1" label="密码"/>
<s:password name="password2" label="再次输入密码"/>
<s:textfield name="work" label="职业"/>
<s:submit value="注册"/>
</s:form>
</body>
</html>
跳转页
<%@ page contentType="text/html; charset=GB2312" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>登陆成功</title>
</head><body>
注册成功!<br>
您的基本信息如下:<br>
用户名:<s:property value="username" /><br>
密 码:<s:property value="password"/><br>
职 业:<s:property value="work"/><br>
</body></html>
action
package package1;import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;public class Chengxu1 extends ActionSupport {
private String username;
private String password;
private String password2;
private String work;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getpassword() {
return password;
}
public void setPwd(String password) {
this.password = password;
}
public String getpassword2() {
return password2;
}
public void setConfirm(String password2) {
this.password2 = password2;
}
public String getwork() {
return work;
}
public void setJob(String work) {
this.work = work;
}
public String execute() throws Exception {
if (this.work == null || "".equals(this.work))
this.setJob("无");
return SUCCESS;
}
@Override
public void validate() {
if (this.username == null || "".equals(this.username))
this.addFieldError("username", "用户名不能为空");
if (this.password == null || "".equals(this.password))
this.addFieldError("password", "密码不能为空");
if (this.password2 == null || "".equals(this.password2))
this.addFieldError("password2", "没有重复输入密码");
if (!this.password2.equals(this.password2)){
this.addFieldError("password2", "两次输入的密码不一致");
}
}
}
配置文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="package1" extends="struts-default">
<action name="Chengxu1" class="package1.Chengxu1">
<result>Chengxu2.jsp</result>
</action>
</package>
</struts>
一个很小的项目老出现 The server encountered an internal error () that prevented it from fulfilling this request,很让我头疼
<%@ page contentType="text/html; charset=GB2312" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>登陆成功</title>
</head><body>
<s:form action="Chengxu1.action" method="post">
<s:textfield name="username" label="用户名"/>
<s:password name="password1" label="密码"/>
<s:password name="password2" label="再次输入密码"/>
<s:textfield name="work" label="职业"/>
<s:submit value="注册"/>
</s:form>
</body>
</html>
跳转页
<%@ page contentType="text/html; charset=GB2312" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>登陆成功</title>
</head><body>
注册成功!<br>
您的基本信息如下:<br>
用户名:<s:property value="username" /><br>
密 码:<s:property value="password"/><br>
职 业:<s:property value="work"/><br>
</body></html>
action
package package1;import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;public class Chengxu1 extends ActionSupport {
private String username;
private String password;
private String password2;
private String work;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getpassword() {
return password;
}
public void setPwd(String password) {
this.password = password;
}
public String getpassword2() {
return password2;
}
public void setConfirm(String password2) {
this.password2 = password2;
}
public String getwork() {
return work;
}
public void setJob(String work) {
this.work = work;
}
public String execute() throws Exception {
if (this.work == null || "".equals(this.work))
this.setJob("无");
return SUCCESS;
}
@Override
public void validate() {
if (this.username == null || "".equals(this.username))
this.addFieldError("username", "用户名不能为空");
if (this.password == null || "".equals(this.password))
this.addFieldError("password", "密码不能为空");
if (this.password2 == null || "".equals(this.password2))
this.addFieldError("password2", "没有重复输入密码");
if (!this.password2.equals(this.password2)){
this.addFieldError("password2", "两次输入的密码不一致");
}
}
}
配置文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="package1" extends="struts-default">
<action name="Chengxu1" class="package1.Chengxu1">
<result>Chengxu2.jsp</result>
</action>
</package>
</struts>
一个很小的项目老出现 The server encountered an internal error () that prevented it from fulfilling this request,很让我头疼
解决方案 »
- Quartz配置cron表达式?
- 页顶 状态栏的显示
- session.getAttribute()的问题 请人帮忙一下...
- <html:form路径问题,达人请来看一下
- 關於iBATIS生成XML文檔的疑問,急,在線等
- jsp实现两个下拉列表联动问题
- 想广交jsp朋友,请加我376666570.共同进步~
- 高分请教:如何用jsp实现在网页中排版编辑(如:http://www.beidou7.com/liudong/edit/example/test.asp)
- 当我请求http://localhost:8080/cbserver/orderForm的时候,能不能给解释一下它的处理过程??
- struts2怎么从一个action传递一个实体到另外一个action
- jsp无法获取超链接中的值
- 数据库是mysql,用abator生成ibatis文件,现在要实现分页查询,该怎么办呢?
这位兄弟写代码的时候要细心点,if (!this.password2.equals(this.password2)){
this.addFieldError("password2", "两次输入的密码不一致");
}这里也很明显有问题,你用password2和password2比较都会返回ture的。
type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception javax.servlet.ServletException: java.lang.NullPointerException
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:422)
private String password1;
private String password2;
private String work;get set方法