在Tomcat上通过eclipse运行项目时的404页面

时间:2014-07-27 08:28:59

标签: java jsp java-ee model-view-controller struts2

使用Struts2,我已经设置了一个非常简单的webapp但是当我在eclipese中运行它时出现404错误..这是我的所有代码和jar文件

网址: localhost:8985 / firststruts / index.jsp

Jar文件

  1. commons-fileupload-1.3.1
  2. 公地-IO-2.2
  3. 公地琅-2.4
  4. 共享记录-1.1.3
  5. 共享记录-API-1.1
  6. 的freemarker-2.3.19
  7. javassist-3.11.0.GA
  8. OGNL-3.0.6
  9. struts2的核 - 2.3.16.3
  10. XWork的核 - 2.3.16.3
  11. struts.xml中

    <?xml version="1.0" encoding="UTF-8" ?>  
    <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts  
    Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">  
    <struts>  
    <package name="default" extends="struts-default">  
    
    <action name="Product" class="com.javatpoint.Product">  
    <result name="success">welcome.jsp</result>  
    </action>  
    
    </package>  
    </struts>      
    

    的web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app>
    <display-name>firstjsp</display-name>
    <filter>  
    <filter-name>struts2</filter-name>  
    <filter-class>  
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter  
    </filter-class>  
    </filter>  
    <filter-mapping>  
    <filter-name>struts2</filter-name>  
    <url-pattern>*</url-pattern>  
    </filter-mapping>  
    </web-app>
    

    product.java

        public class Product {
        private int id;
        private String name;
        private float price;
        public int getId() {
        return id;
        }   
        public void setId(int id) {
         this.id = id;
        }
    
    
       public String getName() {
        return name;
       }
    
       public void setName(String name) {
        this.name = name;
       }
    
       public float getPrice() {
        return price;
       }
    
       public void setPrice(float price) {
        this.price = price;
       }
    
       public String execute() {
        return "success";
       }
       }
    

    的welcome.jsp

    <%@ taglib uri="/struts-tags" prefix="s" %>  
    
    Product Id:<s:property value="id"/><br/>  
    Product Name:<s:property value="name"/><br/>  
    Product Price:<s:property value="price"/><br/>  
    

    index.java

    <%@ taglib uri="/struts-tags" prefix="s" %>  
    <s:form action="product">  
    <s:textfield name="id" label="Product Id"></s:textfield>  
    <s:textfield name="name" label="Product Name"></s:textfield>  
    <s:textfield name="price" label="Product Price"></s:textfield>  
    <s:submit value="save"></s:submit>  
    </s:form>  
    

    我是struts2的新手,所以请帮我解决这个问题。

0 个答案:

没有答案