struts框架编写的用户登陆代码
来源:互联网 发布:js 二维数组定义 编辑:程序博客网 时间:2024/05/21 22:13
1、index.jsp文件
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="x"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<form action="login.action" method="post">
用户名:<input type="text" name="username"><br/>
密码:<input type="password" name="password"><br/>
<input type="submit" value="login">
</form>
</body>
</html>
2、web.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
3、struts.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>
<constant name="struts.i18n.encoding" value="UTF-8" />
<constant name="struts.ui.theme" value="simple"></constant>
<package name="login" extends="struts-default" namespace="/">
<action name="login" class="com.why.actions.LoginAction" method="f1">
<result name="success" type="dispatcher">
/wel.jsp
</result>
<result name="error" type="dispatcher">
/err.jsp
</result>
</action>
</package>
</struts>
4、LoginAction.java文件
package com.why.actions;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport {
private static final long serialVersionUID = 5362742299006067572L;
private String username;
private String password;
public String f1()
{
if("why".equals(username)&&"123".equals(password)){
return "success";
}else{
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;
}
}
- struts框架编写的用户登陆代码
- 用户登陆模块的编写
- 初学者很实用:纯struts框架实现用户登陆
- 用Ext编写的用户登陆
- SSH框架之Struts的有关执行流程的面试题、配置上的共性问题、简单应用-用户登陆
- 框架Struts的action中编写的基于session的购物车逻辑代码
- Struts框架之手工编写代码方式实现校验
- j2ee使用struts实现用户的登陆及注册
- j2ee使用struts实现用户的登陆及注册
- struts入门:struts实现用户登陆
- 登陆用户统计代码!
- struts 用户可选择语言的国际化代码
- struts 过滤器验证用户是否已经登陆
- Struts过滤器实现用户登陆验证
- Struts拦截器判断用户是否登陆
- 简单的登陆确认有无此用户的ajax代码
- 用户登陆代码(转)
- php用户验证登陆代码
- JavaBean封装数据库连接
- android考评系统需求分析报告
- printf和cout的运算顺序
- OpenGL Rendering Pipeline
- 开启Digilent提供的Linux内核的NFS支持
- struts框架编写的用户登陆代码
- 网站对于艺术家信息技术的冲击,世界
- 数据库培训总结
- Smash The Stack Wargame IO Level 01-04
- nfs安装与配置
- javascript 堆栈与列队
- IOS开发之CocoaAsyncSocket学习
- 网络流1飞行员配对方案问题
- Form表单属性及其常用的INPUT控件