struts 搭建成功
来源:互联网 发布:rds数据库 编辑:程序博客网 时间:2024/05/17 08:53
1 下载包,贴到WebContent/WEB-INF/lib 下面
2 写下jsp login.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!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=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<form action="LoginAction.action">
name<input name="username"><br>
pw<input type="password" name="userpass"><br>
<input type="submit" value="login">
<input type="reset" value="cancel">
</form>
</body>
</html>
welcome.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!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=EUC-KR">
<title>Insert title here</title>
</head>
<body>
welcome
</body>
</html>
error.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!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=EUC-KR">
<title>Insert title here</title>
</head>
<body>
error
</body>
</html>
3 写下类
package struts2demo;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport{
private String username;
private String userpass;
public String execute(){
if("1".equals(username)&&"1".equals(userpass))
return SUCCESS;
else
return ERROR;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getUserpass() {
return userpass;
}
public void setUserpass(String userpass) {
this.userpass = userpass;
}
}
4 写在重要的配置 struts.xml 放在src下
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="struts2demo" extends="struts-default">
<action name="LoginAction" class="struts2demo.LoginAction">
<result name="success">/welcome.jsp</result>
<result name="error">/error.jsp</result>
</action>
</package>
</struts>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- struts2 filter -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
这样就ok了
本人验证过
开始 struts吧 加油!!!!
- struts 搭建成功
- struts多模块成功范例
- VPC环境搭建成功
- SharePoint 2007 成功搭建
- wince平台搭建成功!
- CentOS系统搭建成功
- LAMP初步搭建成功
- iBATIS 搭建成功
- LVS成功搭建~~
- kdb 环境搭建成功
- Kylin 环境 搭建 成功
- Hexo 搭建博客(成功)
- 搭建struts 2.0 环境
- 如何搭建struts平台
- 第一课 struts搭建
- MyEclipse搭建Struts程序
- struts框架的搭建
- struts环境搭建
- listView嵌套button或者其它clickable控件时会出现listView的onitemClick事件不响应的问题
- 测试Fragment(跳转回传onActivityResult问题)
- EF6增改删等常用基类
- ubuntu 网络仿真 段错误的一种可能的处理方法
- FindBugs 恶意代码(may expose internal representation),序列化(defines non-transient non-serializable )错误解决方法
- struts 搭建成功
- 关于 Linux C 中的头文件引用可能出现的问题解答
- 通过异类查询(OpenDataSource - OLEDB引擎驱动)把外部数据(Excel,TXT)导入到SqlServer及job代理执行出错的处理
- Unity3D的几种坐标系
- 一般图最大匹配问题-带花树开花算法
- netsh初步--删除无线网与设置共享无线网
- PHP集成百度Ueditor 1.4.3
- HighCharts常用方法总结
- C/C++中判断某一文件或目录是否存在