struts2.5(1)

jar包地址: https://share.weiyun.com/5vDUeWe (密码:cMqf)


不知道为什么,加上这个jar包之后,就不能访问,删除这个jar包就可以访问,还望有大神指点,

web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app id="starter" version="2.4"
         xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <filter>
        <filter-name>action2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
   		
    </filter>

    <filter-mapping>
        <filter-name>action2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
        "http://struts.apache.org/dtds/struts-2.5.dtd">


<struts>
  	<constant name="struts.action.extension" value="do" />
  	 <constant name="struts.enable.DynamicMethodInvocation" value="true"/>
  	 <constant name="struts.convention.action.mapallmatches" value="true"/>
  	 
  	 
  	 
    <package name="default" namespace="/" extends="struts-default">
    	<action name="hello_*" class="com.pay.testS" method="{1}">
    		<result name="success1">/WEB-INF/hello1.jsp</result>
    		<result name="success2">/WEB-INF/hello2.jsp</result>
    		<result name="success3">/WEB-INF/hello3.jsp</result>
    		<result name="success4">/WEB-INF/hello4.jsp</result>
    		<allowed-methods>meth1,meth2</allowed-methods> 
    		<!-- <allowed-methods> 这个是在struts2 2.5之后需要的 -->
    	</action>
    </package>
    
    
    <!--  
    <include file="struts-default.xml"></include>  
    指定默认编码集 
    <constant name="struts.i18n.encoding" value="UTF-8"></constant>  
     指定需要Struts2处理的请求后缀
    <constant name="struts.action.extension" value="do,action"></constant>  
     设置浏览器是否缓存静态内容,开发阶段应关闭,生产阶段打开,默认为打开 
    <constant name="struts.serve.static.browserCache" value="false"></constant>  
     当struts的配置文件修改后,系统是否自动重新加载该文件,默认为false,开发阶段应打开
    <constant name="struts.configuration.xml.reload" value="true"></constant>  
     开发模式下使用,可以打印出更详细的错误信息 
    <constant name="struts.devMode" value="true"></constant>  
    action全部用注解进行配置 
  
    是否开启动态方法调用 
    <constant name="struts.enable.DynamicMethodInvocation" value="false" />  
    添加包 
    <package name="tutorial" extends="struts-default"> 
    	<action name="p" class="JavaSource.AllPersonAction" method="show"> 
    		<result name="all" >all.jsp</result>   
        	<result name="error">error.jsp</result> 
        </action> 
        <action name="testAction" class="com.app.action.TestAction" method="test"> 
        	<result name="all" >all.jsp</result>   
        	<result name="error">error.jsp</result> 
        </action> 
    </package>
    -->
</struts>

action

package com.pay;

public class testS {
	public String meth1() {
		System.out.println("hello1");
		return "success1";
	}
	public String meth2() {
		System.out.println("hello2");
		return "success2";
	}
	public String meth3() {
		System.out.println("hello3");
		return "success3";
	}
	public String meth4() {
		System.out.println("hello4");
		return "success4";
	}
}

jsp


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
	<div><a href="hello_meth1.do">hello_meth1.do</a></div>
	<div><a href="hello_meth2.do">hello_meth2.do</a></div>
	<div><a href="hello_meth3.do">hello_meth3.do</a></div>
	<div><a href="hello_meth4.do">hello_meth4.do</a></div>
</body>
</html>
result的jsp页面都一样
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值