MyException - 我的异常网
当前位置:我的异常网» Java Web开发 » 学习struts遇到的简单有关问题

学习struts遇到的简单有关问题

www.MyException.Cn  网友分享于:2013-02-12  浏览:11次
学习struts遇到的简单问题!
程序功能:
在hello.jsp中点击超联接转到HelloWorld_1.jsp或   HelloWorld_2.jsp

hello.jsp代码:
<html>  
    <body>
        <a   href= "/HelloWorld.do?place=1 "> HelloWorld_1 </a>
        <a   href= "/HelloWorld.do?place=2 "> HelloWorld_2 </a>
    </body>
</html>

HelloAction.java文件内容:
public   class   HelloAction   extends   Action   {
public   ActionForward   execute(ActionMapping   map,   ActionForm   form,
HttpServletRequest   request,   HttpServletResponse     response)   throws   Exception   {
String   para   =   (String)request.getParameter( "place ");
if(para.equals( "1 "))
return   (map.findForward( "Hello_1 "));
                  else  
return   (map.findForward( "Hello_2 "));
}
}

web.xml文件内容:
<web-app>
    <display-name> HelloApp   Struts   Application </display-name>
    <servlet>
        <servlet-name> action </servlet-name>
        <servlet-class> org.apache.Struts.action.ActionServlet </servlet-class>
        <init-param>
            <param-name> config </param-name>
            <param-value> /WEB-INF/struts-config.xml </param-value>
        </init-param>
        <load-on-startup> 2 </load-on-startup>
    </servlet>
    <servlet>
        <servlet-name> action_tmp </servlet-name>
        <servlet-class> org.apache.struts.action.ActionServlet </servlet-class>
        <init-param>
            <param-name> config </param-name>
            <param-value> /WEB-INF/struts-config.xml </param-value>
        </init-param>
        <init-param>
            <param-name> debug </param-name>
            <param-value> 3 </param-value>
        </init-param>
        <init-param>
            <param-name> detail </param-name>
            <param-value> 3 </param-value>
        </init-param>
        <load-on-startup> 0 </load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name> action </servlet-name>
        <url-pattern> *.do </url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file> hello.jsp </welcome-file>
    </welcome-file-list>
    <taglib>
        <taglib-uri> /tags/struts-bean </taglib-uri>

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有