求教structs传值问题

sdliuchenhui sdliuchenhui 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
用的SSH框架,之后下面的代码一直显示没有办法获取到表单中的username和Password的值,输出的值为空值。
求解决办法
之前网上说的方法都有试过,可是哪种方法都是值传不过去
主界面的代码:

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="LoginAction" method="post">
用户名<input type="text" name="username">
密码<input type="text" name="password">
<input type="submit" value="登录">
</form>
</body>
</html>

Struts中的代码:

<package name="testactionpackage" extends="struts-default" namespace="/">
<action name="LoginAction" class="com.action.LoginSystemAction">
<result name="SUCCESS">/success.jsp</result>
<result name="ERROR">/error.jsp</result>
</action>

</package>

LoginSystemAction中的代码:

package com.action;

import com.opensymphony.xwork2.ActionSupport;

public class LoginSystemAction extends ActionSupport
{
private String username;
private String password;
@Override
public String execute()throws Exception
{
if("test".equals(username)&&"123456".equals(password))
{
return "SUCCESS";
}else{
System.out.println(username);
System.out.println(password);
return "ERROR";
}
}

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;
}

}
...全文
评论 5
收藏 已收藏
分享
返回顶部
sdliuchenhui
Web 开发 81,108 成员 341,721 内容