第一个成功的struts项目
来源:互联网 发布:万象网管数据库密码 编辑:程序博客网 时间:2024/04/19 17:42
__________________________________第一个成功的struts项目_____________
//////login.jsp://////////
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'result.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>
username:${requestScope.username} <br/>
password:${requestScope.password}
</body>
</html>
_____________________________________________________________
////web.xml://///
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<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>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
_______struts.xml__________________________________________________
<?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="struts2" extends="struts-default">
<action name="login" class="com.test.action.LoginAction">
<result name="success">/result.jsp</result>
</action>
</package>
</struts>
_________LoginAction.java_____________________
package com.test.action;
public class LoginAction {
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
{
return "success";
}
}
__________result.jsp_____________________________________________
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'result.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>
username:${requestScope.username} <br/>
password:${requestScope.password}
</body>
</html>
____________________________________________________________
在Preferences/Java/Editor/Content Assist中的Auto activation triggers for Java中的将.改为.abcdefghijklmnopqrstuvwxyz
/////////////////////////////////////////JavaBean//////////////////////////////////////
////index.jsp
<%@ page language="java" contentType="text/html; charset=GB18030" pageEncoding="GB18030"%>
<!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=GB18030">
<title>Insert title here</title>
</head>
<body>
<form action="reg.jsp" method="post">
<input type="text" id="useName" name="userName"><br/>
<input type="text" id="pwd" name="pwd"><br/>
<input type="submit" value="注册">
</form>
</body>
</html>
////////////reg.jsp
<%@ page language="java" contentType="text/html; charset=GB18030" pageEncoding="GB18030"%>
<!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=GB18030">
<title>Insert title here</title>
</head>
<body>
<jsp:useBean id="reg" class="com.bean.ClassBean" scope="page">
<jsp:setProperty name="reg" property="*" />
</jsp:useBean>
用户名为:<jsp:getProperty property="userName" name="reg"/>
<br/>密码为:<jsp:getProperty property="pwd" name="reg"/>
</body>
</html>
/////////ClassBean.java
package com.bean;
public class ClassBean {
private String userName;
private String pwd;
public String getUserName()
{
return userName;
}
public String getPwd()
{
return pwd;
}
public void setUserName(String userName)
{
this.userName=userName;
}
public void setPwd(String pwd)
{
this.pwd=pwd;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////
- 第一个成功的struts项目
- 第一个成功的struts项目
- 第一个Struts项目
- 第一个成功的Hibernate项目
- 基于Struts的第一个项目
- spring+hibernate的第一个项目成功后的总结
- 我的第一个多线程项目终于成功了
- 第一个软件的成功
- Windows下使用Cordova跨平台框架开发的成功的第一个android项目
- NHibernate第一个成功的例子 (引用)
- 第一个成功的Hibernate实例
- 菜鸟成功修改的第一个程序
- 第一个成功的MFC对话框程序
- 第一个成功的Hibernate实例
- css (第一个较为成功的css)
- Eclipse3.5下的struts2的配置,以及建立第一个struts项目HelloWorld
- 使用手动配置的方式开发第一个Struts项目的步骤以及实例
- 你的第一个struts应用程序
- (转)C语言家族扩展
- 学习Oracle,从今天开始
- Java MD5加密
- 计算机期刊
- MFC中的几种播放声音的方法
- 第一个成功的struts项目
- linux 下dmalloc安装及环境配置
- 推荐16本学习JavaScript的书籍
- ShellExecute隐式调用批处理并等待返回
- 查找另一个程序,并将其显示在最前端
- 文本编辑软件UltraEdit v16.20官方简/繁体中文版下载+注册码和破解方法
- VS2005链接问题: LNK2005错误 :error LNK2005: _free 已经在 libcmtd.lib(dbgheap.obj) 中定义
- 用于STM32的gcc编译器
- 求助,Java中byte[]转String,String再转byte[] ,其结果不一样!!