java - 创建struts2项目显示“HTTP Status 404 ”
迷茫
迷茫 2017-04-17 11:55:46
[Java讨论组]

初学struts,按照书上app02a写的程序,不知道为什么会报错。

1.web.xml



    struts
    
        index.html
        index.htm
        index.jsp
        default.html
        default.htm
        default.jsp
    

    
        struts2
        org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter
    

    
        struts2
        /*
    
    
        
            JSPs
            /jsp/*
        
        
    
    
        BASIC
    

2.struts.xml






      
     

    
        
            /jsp/ProductForm.jsp
        
        
            /jsp/ProductDetails.jsp
        
    

3.Product.java

package com.imjian.struts;

import java.io.Serializable;

public class Product implements Serializable {
    private String productName;
    private String description;
    private String price;

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public String execute(){
        return "seccess";
    }
}

启动tomcat的时候没有报错;
当我输入http://localhost:8080/struts/Product_input.action时,会得到:

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

全部回复(2)
巴扎黑

好吧,是我买的书过时了,把web.xml改成

<filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>

就好了。

ringa_lee

已经被替换了

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号