这是loginAction代码:
public class LoginAction extends ActionSupport{
private String username;
private String password;
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;
}
public String check(){
if(getUsername().equals("scott")&&getPassword().equals("tiger")){
System.err.println(username);
ActionContext.getContext().put("user",username);
return SUCCESS;
}
else{
return LOGIN;
}
}
}
//=================================================================
这是JSP页面代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>welcome</title>
</head>
<body>
welcome,${sessionScope.user}!
<form action="showBooks.action" method="post">
<input type="submit" value="show books">
</form>
</body>
</html>
//===========================================================================
问题就是:在JSP页面中获取不到user的值,编译不报错,求助!!
public class LoginAction extends ActionSupport{
private String username;
private String password;
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;
}
public String check(){
if(getUsername().equals("scott")&&getPassword().equals("tiger")){
System.err.println(username);
ActionContext.getContext().put("user",username);
return SUCCESS;
}
else{
return LOGIN;
}
}
}
//=================================================================
这是JSP页面代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>welcome</title>
</head>
<body>
welcome,${sessionScope.user}!
<form action="showBooks.action" method="post">
<input type="submit" value="show books">
</form>
</body>
</html>
//===========================================================================
问题就是:在JSP页面中获取不到user的值,编译不报错,求助!!
解决方案 »
- org.springframework.orm.hibernate3.LocalSessionFactoryBean的疑惑
- Java中怎么将字符串的格式转成时间格式
- struts2表单提交数据类型转换失败后仍然转入success配置页面
- [Microsoft][ODBC SQL Server Driver]无效的描述符索引 请帮忙看看是什么错误啊!
- 在jsp中怎样根据插入的数据动态设置表格的宽度。
- 用<script>parent.from.Text1.value='2'</script>怎么保留已有的内容
- Trace有人用过吗?
- 用poi读excel文件内容,单元格的类型问题
- 初学者简单问题,做一个添加用户,用户登陆的程序出错帮忙看一下。QQ25096679
- springcloud框架,zuul做网关,想要实现访问同一个接口,登录用户和未登录用户看到的数据不一样,怎么做
- 扫描身份证如何在jsp中显示个人信息
- 用过MULE esb 的进,在线等回复
ActionContext.getContext().put("user",username);这句少了一部分,正确的是ActionContext.getContext().getSession().put("user",username);
细心!一定要细心!