读书人

Tamcot与struts2的有关问题

发布时间: 2012-02-13 17:20:26 作者: rapoo

Tamcot与struts2的问题?
我在Tamcat文件conf/server.xml中配置: <Context path = "/st " docBase = "D:\Program Files\struts2-blank "/>
我的D:\Program Files\struts2-blank文件有三个目录文件,分别是:jsp,WEB-INF ,还有一个study.html文件。里面的内容是:


study.html内容:
<% page contentType = "text/html " pageEncoding= "GBK "%>
<html>
<head>
<title> aaaaaaaaaaaaaa </title>
</head>
<body>
<h1> 加油!!!!加油!!!!! </h1>
</body>
</html>

此时WEB-INF文件夹下的web.xml的配置如下:
<?xml version= "1.0 " encoding= "ISO-8859-1 "?>
<welcome-file-list>
<welcome-file> index.html </welcome-file>
</welcome-file-list>
<description>
Welcome to Tomcat
</description>

</web-app>


这个时候,我起动Tomcat,在浏览器中输入:http://localhost:8080/st/,就可以见到jsp文件夹和study.html文件。

我在WEB-INF文件夹下增加一个文件名字叫classes,在它下面放一个文件struts.xml;
struts.xm的配置如下:

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

<struts>
<package name= "default " namespace= "/ " extends= "struts-default ">
</package>
</struts>

然后我把Web.xml的配置也改了:
<?xml version= "1.0 " encoding= "ISO-8859-1 "?>
<welcome-file-list>
<welcome-file> index.html </welcome-file>
</welcome-file-list>
<description>
Welcome to Tomcat
</description>

[color=#FF0000] <display-name> Struts Blank </display-name>

<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> [/color] </web-app>

我再起动Tomcat,在浏览器中输入:http://localhost:8080/st/,[color=#FF0000]却看不到jsp文件夹和study.html文件,这是为什么呢?[/color]
有哪位可以说明一下这个现象?




[解决办法]
要代码变颜色,需要在你发帖时,点上方的“插入源代码”选择相应的语言就行了。
[解决办法]
你这样是不适用编译器手动在Tomcat中搭建struts2框架么?


先说明一点这样写很容易出错,我也没这样写过,我都是使用myEclipse做java项目的。
你现在是在练习的么?建议你还是使用编译器吧。
我还不明白你使用的[color=#FF0000] 标签使用来干什么的,干嘛用它来将Struts2的核心控制器给包住呢
如果没什么特殊作用的话把[color=#FF0000] 标签删了吧,直接访问http://localhost:8080/st/就能访问到了
[解决办法]
默认打开的是index.html~~~~大家都努力学习
[解决办法]
不是的啦。。应该这样访问http://localhost:8080/str/study.html
如果你要http://localhost:8080/str/这样访问study.html的话,需要将web.xml文件改一下
改为:

XML code
     <welcome-file-list>                 <welcome-file> index.html </welcome-file>         </welcome-file-list> 

读书人网 >Java Web开发

热点推荐