解决方案 »
- 有人用过javafx吗
- struts2在jsp中对list集合相同值的进行动态合并单元格
- jsf中使用flahs上传文件,如何上传?
- 请教高手,RAD7.5中MQ的包是哪个。。
- 200分问问题(2)
- hibernate关于多对多关系的关联表中的插入问题
- jsp使用JNDI数据源连接Mysql数据库出现中文乱码,不要别写数据类型转换的方法,还有什么可以解决这个问题?
- 请问在hibernat中,如何直接执行sql语句,不牵涉到对象查询
- 这样的效果怎样实现啊?
- 高分求用jbuilder 构建的Struts例子 最好是Weblogic 做server
- 急!!!急!!!J2EE的有关问题
- SSH 项目图标上有红叉 文件没错 一开始能运行 突然就就不行了
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
访问不了。
我将web.xml中的
<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>删了的话,可以访问到index.jsp的内容,但也无法访问hello.jsp
改成
<action name="hello" class="com.club.web.action.HelloAction" method="execute">
好像不只这一个错误,你先把这个改了试下,这代码哪来的?
改了,也不行,来源:http://singandsuny.blog.163.com/blog/static/1866688220101195258138/
改了,也不行,来源:http://singandsuny.blog.163.com/blog/static/1866688220101195258138/
下次看之前先看下评论,评论好的才看,这个好多错误
<result name="success">/WEB-INF/page/hello.jsp</result>
改成<result name="success">page/hello.jsp</result> 在试下
<struts>
<package name="default" namespace="/test" extends="struts-default">
<!-- 下面的action缺少了个class属性 是用来指定哪个Action类的 所以如下 -->
错误:<action name="hello" method="execute">
真确:<action name="hello" class="com.club.web.action.HelloAction" method="execute">
<!-- result标签下面指定的地址是这样的 -->
错误:<result name="success">/WEB-INF/page/hello.jsp</result>
真确:<result name="success">page/hello.jsp</result>
</action>
</package>
</struts>做完这些应该可以获取到了吧。
<package name="default" namespace="/" extends="struts-default">
<action name="hello" class="com.club.web.action.HelloAction">
<result name="success">/page/hello.jsp</result>
</action>
</package>
</struts>
actio里最好指明包,同时是默认执行execute()方法
result访问里不需要WEB-INF目录
你在地址栏输入http://localhost:8080/struts/hello.action就ok了
把page文件下的hello.jsp放到webroot下,完后再修改一下struts.xml试试 <result name="success">/page/hello.jsp</result>
WEB-INF是Java的WEB应用的安全目录。所谓安全就是客户端无法访问,只有服务端可以访问的目录。
如果想在页面中直接访问其中的文件,必须通过web.xml文件对要访问的文件进行相应映射才能访问。
WEB-INF文件夹下除了web.xml外,还存一个classes文件夹,用以放置 *.class文件,这些 *.class文件是网站设计人员编写的类库,实现了jsp页面前台美工与后台服务的分离,使得网站的维护非常方便。web.xml文件为网站部署描述XML文件,对网站的部署非常重要。
在WebRoot下建立/pages/hello.jsp 再试试
http://localhost:8080/struts/test/hello