雅典之夏的小站
知人者智 自知者明 Fighting!!

1、简介

            简单的页面输入并显示的功能,有两个页面,
            upnews.jsp 提供输入内容的界面,show.jsp显示已经输入的内容

2、源码
      struts-config,流程图

Snap3.jpg
源代码
Strust-config.xml

<form-bean name="upNewsForm" type="com.rkind.struts.form.UpNewsForm" />
        <action attribute="upNewsForm" input="/upNews.jsp" name="upNewsForm" path="/upNews" scope="request" type="com.rkind.struts.action.UpNewsAction">
            
<forward name="suc" path="/show.jsp" redirect="true" />
        
</action>


upnews.jsp
     都是eclispe自动生成的
<html:form action="/upNews">
            content : 
<html:text property="content"/><html:errors property="content"/><br/>
            
<html:submit/><html:cancel/>
        
</html:form>

show.jsp这个简单就一句话,
<bean:write name="upNewsForm" property="content"/>

模型的部分 formbean,自动生成,未做改动
Controller部分,核心啊
UpNewsForm upNewsForm = (UpNewsForm) form;
        
// TODO Auto-generated method stub
        String te=upNewsForm.getContent();
        
try{
        
if(te.equals("")){
            
return new ActionForward(mapping.getInput());        
        }

        
return (mapping.findForward("suc"));
        }
catch(Exception e){
            
throw new RuntimeException(e.getMessage());

好了,但是在测试的时候一直出问题,输入以后不能正常,原因有2
1、在链接时候,没有加“/”导致不能正常连接
2、forward name="suc" path="/show.jsp" redirect="true" 起初没有加redirect,不能跳转。
posted on 2006-10-27 12:39 rkind 阅读(468) 评论(0)  编辑  收藏 所属分类: Struts

只有注册用户登录后才能发表评论。


网站导航: