今日复习,发现好多知识点都已经很是模糊,决定以后认真复习,并记录之。
---struts2登录---
1、strust.xml内容:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<package name="defualt" namespace="/" extends="struts-default">
<action name="login" class="com.he.action.LoginAction">
<result name="success">success.jsp</result>
<result name="input">login.jsp</result>
</action>
</package>
</struts>
2、login.jsp内容:
<body>
<form action="login.action" method="post">
<table border="1" cellpadding="0" cellspacing="0" bordercolor="red">
<tr>
<td>
用户名
</td>
<td>
<input type="text" name="username" />
</td>
</tr>
<tr>
<td>
密 码
</td>
<td>
<input type="password" name="password" />
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="login" />
</td>
</tr>
</table>
</form>
</body>
3、LoginAction.java内容:
package com.he.action;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
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 execute() throws Exception
{
if(!username.equals("")&&!password.equals("") )
{
ActionContext.getContext().getSession().put("username", username);
return Action.SUCCESS ;
}else{
return Action.INPUT ;
}
}
}
分享到:
相关推荐
J2EE考试复习试题_struts2_spring_hiberna,很好的学习资料哦
整合最全的struts2_spring_hibernate
struts2-scan 检测struts2漏洞,认证检测struts2漏洞
20110930_Struts2_0100_Introduction20110930_Struts2_0100_Introduction20110930_Struts2_0100_Introduction20110930_Struts2_0100_Introduction20110930_Struts2_0100_Introduction
Struts2入门教程_Struts2入门教程_skindzj_.zip
Struts2_1000_CharacterEncodingStruts2_1000_CharacterEncodingStruts2_1000_CharacterEncoding
Struts2_interceptor_和_filter区别
Struts2和JSON交互的例子,非常容易理解,Struts2和JSON交互的例子,非常容易理解。
官方描述: ... ... 官方建议修复方案:升级到最新版本 struts-2.3.15.1 但通常现有系统升级,可能导致不稳定及与其他...鉴于此csdn网友jzshmyt整理了一种既可以不用升级现有struts版本,有能完美解决这两个漏洞的方案,
struts2_spring_hibernate jar图struts2_spring_hibernate jar图struts2_spring_hibernate jar图
struts2_spring_hibernatestruts2_spring_hibernate
struts2_hibernate_spring日程管理系统
struts2_mybatis_spring_框架整合实例_数据库 源码中包括数据库文件 文档介绍
Struts2_1100_SimpleDataValiation
SSM框架整合
struts2_core_JAR开发包 MVC思想Xwork为技术核心。
Struts2_0500_ActionMethodStruts2_0500_ActionMethodStruts2_0500_ActionMethod
struts2_spring_mybatis整合案例
ssi_struts2_spring_ibatis oracle数据库.增删改查分页 示例.有简单页面.好资料.!