struts.xml小问题
<global-exception-mappings>
<exception-mapping exception="com.ssh.common.core.ProjectException" result="exception" />
</global-exception-mappings>
<global-results>
<result name="exception">
<param name="location">/common/error.jsp</param>
</result>
<result name="login">/login.jsp</result>
</global-results>
web.xml问题
<!-- 加载spring的配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-*.xml</param-value>
</context-param> <!-- spring 提供的字符串过滤器 -->
<filter>
<filter-name>Spring character encoding filter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Spring character encoding filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
麻烦各位了,,有点不太懂,这些配置在什么情况下被什么调用,产生什么样的结果,还有这些配置好像有点乱,,什么样的配置应该放在struts.xml,,,,什么样的配置应该放在web.xml,,,什么样的配置应该放applicationContext.xml里面???
<global-exception-mappings>
<exception-mapping exception="com.ssh.common.core.ProjectException" result="exception" />
</global-exception-mappings>
<global-results>
<result name="exception">
<param name="location">/common/error.jsp</param>
</result>
<result name="login">/login.jsp</result>
</global-results>
web.xml问题
<!-- 加载spring的配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-*.xml</param-value>
</context-param> <!-- spring 提供的字符串过滤器 -->
<filter>
<filter-name>Spring character encoding filter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Spring character encoding filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
麻烦各位了,,有点不太懂,这些配置在什么情况下被什么调用,产生什么样的结果,还有这些配置好像有点乱,,什么样的配置应该放在struts.xml,,,,什么样的配置应该放在web.xml,,,什么样的配置应该放applicationContext.xml里面???
struts.xml是用来配置MVC中的MV
applicationContext.xml是spring的配置文件,一般要来配置事务管理和控制反转
其实还有很多,很难全部说完,你还是自己多看书吧
想拿点分真难
1.首先struts.xml,你设置的是一个出现异常转向,主要出现你定义的异常,就会跳转到common/error.jsp页面。然后你这样配置需要在每个package中这样配置,最好将这部分抽取中一个xml,然后在struts.xml继承这个抽取的xml就行了。
2. web.xml问题
web.xml肯定是服务器一启动就要加载的选项,spring的配置信息,过滤器等等都是要在web.xml中配置的。struts.xml主要是为了配置action的,web.xml配置的东西就多了,除了上面的以外,可以配置监听,serlvet,根本状态吗,返回的错误页面等等。applicationContext.xml配置些IOC,AOP了,数据库信息了以及乱七八糟的东西- -!
其实没必要这样去理解,用多了自然就习惯了!
<!-- 加载spring的配置文件 -->
<context-param>
<param-name>contextConfigLocation </param-name>
<param-value>/WEB-INF/applicationContext-*.xml </param-value>
</context-param> <!-- spring 提供的字符串过滤器 简单说处理中文 -->
<filter>
<filter-name>Spring character encoding filter </filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter </filter-class>
<init-param>
<param-name>encoding </param-name>
<param-value>UTF-8 </param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Spring character encoding filter </filter-name>
<url-pattern>/* </url-pattern>
</filter-mapping>
放到web.xml里面你都写注释了啊
你的struts是struts2还是struts1呢
web.xml肯定是服务器一启动就要加载的选项,spring的配置信息,过滤器等等都是要在web.xml中配置的。struts.xml主要是为了配置action的,web.xml配置的东西就多了,除了上面的以外,可以配置监听,serlvet,根本状态吗,返回的错误页面等等。applicationContext.xml配置些IOC,AOP了,数据库信息了以及乱七八糟的东西- -!
很详细啊