最简单的struts2-convention-plugin2.2.1的例子

来源:百度文库 编辑:神马文学网 时间:2024/04/28 14:53:12
环境说明:MyEclipse 8.6.1JDK1.6.0_21Tomcat 6.0.29 项目结构如下:    web.xml 
 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">
 
  struts2
  org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
 
 
  struts2
  /*
 

 
  index.jsp
 

 
 struts.xml  
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" 
    "http://struts.apache.org/dtds/struts-2.0.dtd"> 
        
     
      
          
     index.jsp <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

 
   
   
    My JSP 'index.jsp' starting page
 
 
    
 
 
 
 
 
 
 
    This is my JSP page.

 

 hello-world.jsp 

Hello world!

 以上为所有项目文件代码,jar包为官方包。。。 运行截图    使用struts convention一定要细心!弄了一天,终于好了,结果还不知道到底刚开始是哪里错了   另:最好不要配,
   /page/error.jsp
  
刚开始一直是默认跳到error.jsp后注释了这两个之后就正常了。。。不知道大家碰到过这种问题没。。。