javaweb action无法跳转、表单无法跳转的解决方法

2014-11-23 21:55:15 · 作者: · 浏览: 8
action无法跳转,表单无法跳转的解决方法
action无法跳转、表单无法跳转的原因: 说明 :在确保你项目的其它action、表单能正常跳转的情况下,查找以下3个原因。
1、确认action中有无写错,struts中有无指定action的class 如: ,如果后台java中没有这里class指定的路径,那么将无法跳转

2、表单有没有后缀,如指定后缀是action,则一定要配置 *.action /*
3、form表单中的action是否能够与struts.xml里action的name匹配 如: jsp表单
,如果在struts.xml找不到 (这里的*User,*是通配符)或 ,将无法跳转

jsp form表单中的action无法跳转 如果表单中action中没有后缀,使用 *.action 这种配置将无法跳转,因为匹配不了后缀名,
使用 *.action tern> 时 如: 1、
action有后缀名,这种能正常跳转 2、 action没有后缀名,无法跳转
但如果使用 /* 在表单中即使action中没有后缀名,即, 也能跳转
如果表单正常跳转,控制台应该会打印出这个方法,如: 2014-05-06 12:11:52,404 DEBUG (org.apache.struts2.interceptor.FileUploadInterceptor:68) - Bypassing //saveChild 2014-05-06 12:11:52,407 DEBUG (org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor:68) - Validating //saveChild with method save.
根据我自己的经验,如果控制台没有打印出“Bypassing // action名”,那么表单的action都是无法正常跳转到后台的
/*
使用 /* 这种会将servlet拦截了,如果项目中有单独创建的servlet,那么将无法访问这个servlet,如平时使用servlet创建一个验证码的链接
所以如果要使用验证码的servlet,那么就将使用以下这种配置了
struts *.action *.jsp
jsp访问时,无法访问 如果只定义了 *.action ;而没有定义 *.jsp ,那么jsp也将无法访问

一个通过测试的web.xml文件。没有给出web.xml文件头,因为包含了url,博客不准发url
unionweb org.springframework.web.context.ContextLoaderListener contextConfigLocation classpath:applicationContext.xml struts org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter struts *.action *.jsp login.jsp
说明:以上全部都是我自己经过测试的,如说的不对,还望大家指出