JEE_框架配置问题集锦

//导包 要导入的包最好是从Struts2的app程序中拷贝,要的配置文件从例子中copy改!!

 

Struts2:

// WEB-INF文件夹下的文件只能被服务器方法,对客户端是隐藏的。 内部的请求转发可以访问,但浏览器重定向则是访问不了的。

// 解决Struts.xml无法自动提示输入的问题。    window--->preference--->XML--->XML catalog--->User Specified Entries---> add->其中key Type选择URI ,Key 选择DTD中那个key 地址, Location 选择dtd文件在本地硬盘上的完整路径。

// eclipse中提示struts.xml错误问题 这个可能是你的DTD文件找不到,或者解析有错,才发生的错误, 重新设置dtd文件使其可以自动搜索到并自动提示.

// web.xml中<filter-class>的配置: Struts2.1.3之前用的是: <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class> 之后用的是: <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>

//DTD信息:这些web.xml,struts.xml和要导入的包最好是从Struts2的app程序中拷贝。 web.xml:

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
 id="WebApp_ID" version="3.0">

<web-app id="WebApp_9" 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">

 

Struts.xml:

<!DOCTYPE struts PUBLIC
 "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
 "http://struts.apache.org/dtds/struts-2.3.dtd">

这个声明可以在项目下面Referenced Libraries下struts2-core-2.2.3.jar下struts-default.xml找到.

 

 

======================================================== //web.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
 id="WebApp_ID" version="3.0">
 <welcome-file-list>
  <welcome-file>login.jsp</welcome-file>
 </welcome-file-list>
 <filter>
  <filter-name>struts2</filter-name>
  <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
 </filter>
 <filter-mapping>
  <filter-name>struts2</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.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
 <package name="mao" extends="struts-default">
  <action name="login" class="mao.s.LoginAction">
   <result name="success">/welcome.jsp</result>
  </action>
 </package>
</struts>

 

 

 

posted @ 2012-08-14 18:49  汤姆是一只猫  阅读(165)  评论(0编辑  收藏  举报