| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 912 人关注过本帖
标题:Jcreator中怎样引入Struts包
只看楼主 加入收藏
ming206
Rank: 2
来 自:重庆
等 级:等待验证会员
威 望:3
帖 子:545
专家分:7
注 册:2005-8-2
结帖率:100%
收藏
 问题点数:0 回复次数:1 
Jcreator中怎样引入Struts包

急,在线!
/*
*包名?JavaBean
*类名:LoginAction
*功能:处理表单数据
*/
package JavaBean;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
****************等等
编译时, 提示找不到HttpServletRequest,Action等

怎么配置JCREATOR?是Struts包还没引入,怎么因入?

搜索更多相关主题的帖子: import Jcreator Struts apache action 
2006-03-03 22:52
ming206
Rank: 2
来 自:重庆
等 级:等待验证会员
威 望:3
帖 子:545
专家分:7
注 册:2005-8-2
收藏
得分:0 

全部程序如下:
/*
*包名?JavaBean
*类名:UserForm
*功能:接收表单数据
*/
package JavaBean;

public class UserForm extends ActionForm{//ActionForm的子类
private String username=null;
private String passwd=null;
public UserForm(){}
//Set The Propety
public void setUsername(String username){
this.username=username;
}
public void setPasswd(String passwd){
this.passwd=passwd;
}
//Get The Propety
public String getUsername(){
return username;
}
public String getPasswd(){
return passwd;
}

}

//简单测试的BEAN
package JavaBean;
//纯javabean
public class CheckName{
String username=new String();
String passwd=new String();
public CheckName(String username,String passwd){
this.username=username;
this.passwd=passwd;
}
public Boolean Succsse(){
Boolean f=new Boolean(false);
try{
if(username=="ming206"&&passwd=="123456"){
f=new Boolean(true);
}
}catch(Exception e){System.out.print("错误:"+e.getMessage());}
finally{
//返回正确与否
return f;
}
}
}

/*
*包名?JavaBean
*类名:LoginAction
*功能:处理表单数据
*/
package JavaBean;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public final class LoginAction extends Action{//Action的子类
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception{
UserForm userform=(UserForm) form;
String name=userform.getUsername();
String pwd=userform.getPasswd();
Boolean c=new Boolean(false);
try{
Boolean c=new Boolean(new CheckName(name,pwd).Succsse());
if(c){
//用户名和密码都正确时转向right.jsp页面
return mapping.findForword("Successed");
}else{
//否则转向error.jsp页面
return mapping.findForword("Failed");
}

}catch(Exception e){out.print(e.getMessage());}
}

}

struts-config.xml文件:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE struts-config PUBLIC
"-//Apache software Foundtion//DTD Struts Configration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

<strutes-config>
<!--ActionForm Bean-->
<form-beans>
<form-bean name="formBean1" type="JavaBean.UserForm"/>
</form-beans>

<!--ActionForward-->
<global-forwards>
<forward name="Failed" path="/error.jsp"/>
<forward name="Successed" path="/right.jsp"/>
</global-forwards>

<!--Action Bean-->
<action-mappings>
<action path="/login" type="JavaBean.LoginAction" name="formBean1" scope="request" input="login.jsp"/>
<action path="/regist" forward="regist.jsp"/>
</action-mappings>

</struts-config>


外贸综合平台:E贸通
2006-03-03 22:59
快速回复:Jcreator中怎样引入Struts包
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015460 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved