问题描述
我的jsp<%@pagelanguage="java"import="java.util.*"pageEncoding="utf-8"%><%Stringpath=request.getContextPath();StringbasePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"><html><head><linkhref="css/bootstrap.min.css"rel="stylesheet"type="text/css"/><scripttype="text/javaScript"src="js/jquery-1.9.1.min.js"></script><scripttype="text/javaScript"src="js/bootstrap.min.js"></script><title>考试管理系统</title><metahttp-equiv="pragma"content="no-cache"><metahttp-equiv="cache-control"content="no-cache"><metahttp-equiv="expires"content="0"><metahttp-equiv="keywords"content="keyword1,keyword2,keyword3"><metahttp-equiv="description"content="Thisismypage"><!--<linkrel="stylesheet"type="text/css"href="styles.css">--></head><divclass="container-fluid"><divclass="row-fluid"><divclass="span12"><h3class="text-center">在线考试管理系统</h3><ulclass="navnav-tabs"><liclass="active"><ahref="#">首页</a></li><li><ahref="#">登录</a></li><li><ahref="#">退出</a></li><li><ahref="register/register">注册</a></li><liclass="dropdownpull-right"><aclass="dropdown-toggle"data-toggle="dropdown"href="#">快捷操作</a><ulclass="dropdown-menu"><li><ahref="#">密码找回</a></li></ul></li></ul></div></div></div><body><br></body></html>我的struts.XML<?xmlversion="1.0"encoding="UTF-8"?><!DOCTYPEstrutsPUBLIC"-//ApacheSoftwareFoundation//DTDStrutsConfiguration2.0//EN""http://struts.apache.org/dtds/struts-2.0.dtd"><struts><packagename="default"extends="struts-default"namespace="register"><actionname="register"class="com.zyb.action.Register"><resultname="ok">register.jsp</result></action></package></struts>我的action类packagecom.zyb.action;importcom.opensymphony.xwork2.ActionSupport;publicclassRegisterextendsActionSupport{/****/privatestaticfinallongserialVersionUID=1L;publicStringexecute(){return"ok";}}---------------------------------------action找不到?求解释。谢谢
解决方案
解决方案二:
你的jsp放在哪个目录下面的?
解决方案三:
放在webroot下面了
解决方案四:
看下你的配置吧,一般找不到ACTION,都是配置未配好导致的。。
解决方案五:
你的web.xml怎么配,过滤器那里,会不会配了后缀.do,访问url却没加.do<filter-mapping><filter-name>struts2</filter-name><url-pattern>/*.do</url-pattern></filter-mapping>
解决方案六:
引用2楼u010175788的回复:
放在webroot下面了
那就对了,你在配置文件中指定了namespace=register<packagename="default"extends="struts-default"namespace="register">那么struts找的时候,会先找register/register.action,然后再到默认命名空间下找register.action也是没有的而此时你的文件在webroot下,对应的是默认默认命名空间所以此时解决方法,要么去掉namespace="register",要么把这个jsp放在webroot/register目录下
解决方案七:
我的是因为jar包的版本不对,,我用A版本写了个action然后importA的东西。。。发现不行找不到。然后换用B版本,结果还是找不到。其实我把那个Struts.xml首字母大写了。然后改成小写。在启动tomcat发现,自动弹出debug。我又把Action类从新写了一下,就OK了。。。namespace不写相当于有个/
解决方案八:
struts这个配置文件是个错误但是不管换几个版本,只要你不改变一开始你配置的namespace,然后你那个jsp还是放在webroot下面,肯定还是找不到
解决方案九:
哥们你的<base><%=basePath%></base>好像没写啊那就得要用绝对地址啊
解决方案十:
解决方案十一:
namespace改为/register,应该可以了
解决方案十二:
大神你好。我在学习java,你的这个在线考试系统能不能给我借鉴1340517737@qq.com
解决方案十三:
首先观察你页面上注册的链接写对吗?namespace好像应该是/register
解决方案十四:
/register貌似正解