那位可有LoginAction的例题?Struts框架

qzdsq 2005-02-28 04:17:51
那位可有LoginAction的例题?Struts框架

<html:form action="login" >
<tr><td>用户:</td>
<td><input type="text" name="username"></td>
</tr>

<tr><td>密码:</td>
<td><input type="password" name="password"></td></tr>


<tr><td></td>
<td></td></tr>
</html;form>
...全文
65 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
edward1026 2005-03-01
  • 打赏
  • 举报
回复
你的Action的execute没有定义找不到session的时候返回login.jsp
qzdsq 2005-02-28
  • 打赏
  • 举报
回复
public class view extends baseview(){
public String username=null;
public String password=null
public view{
super()
};

public String getusername(){
this.username;
}

public void setusername(String username){
this.username=username;
}public String getpassword(){
this.password;
}

public void setpassword(String username){
this.password=username;
}
public String getView(){
this.View;
}

public void setView(String View){
this.View=View;
}





}
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
// HttpSession session = null;
String user = null;
String target = new String("success");
String username = ((LoginForm)form).getUsername();
String password = ((LoginForm)form).getPassword();
user = checkUser(username, password);
view view=null;
HttpSession session = getSession(false);
if ( session == null ) {
session.invalidate; }
else {
view view=new view();
view.setView(user);
session=request.getSession(true);
session.setAttribute("view",view)

}
return (mapping.findForward(target));
}
}
在这段代码中我想用session限制用户必须经过login.jsp才能登录到index.jsp,请问

这样行吗,为什么?怎么做呢?

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧