欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

JAVA EE里的一些配置文件

程序员文章站 2022-05-27 16:18:23
...
这段时间在写毕业设计,用到了SSH三大框架的一些技术,但是自己在配置配置文件的时候发现自己对一些配置文件的了解和记忆还不是很牢靠,现在整理下一些常用的配置文件,以便下次使用和复习

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:jsp="http://java.sun.com/xml/ns/javaee/jsp" 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" version="3.0">
<session-config>
<session-timeout>120</session-timeout>
</session-config>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath://spring/**/*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>encodingFilter</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>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<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>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<error-page>
<error-code>404</error-code>
<location>/404.jsp</location>
</error-page>
<jsp-config>
<jsp-property-group>
<description>Special property group for html Configuration JSP example.</description>
<display-name>JSPConfiguration</display-name>
<url-pattern>*.html</url-pattern>
<el-ignored>true</el-ignored>
<page-encoding>UTF-8</page-encoding>
<scripting-invalid>false</scripting-invalid>
<include-prelude></include-prelude>
<include-coda></include-coda>
</jsp-property-group>
</jsp-config>
</web-app>

struts.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
"http://struts.apache.org/dtds/struts-2.1.7.dtd">
<struts>
<!-- struts constants-->
<constant name="struts.multipart.maxSize" value="2000000000" />
<constant name="struts.multipart.saveDir" value="/tmp" />
<constant name="struts.custom.i18n.resources" value="i18n/message,i18n/actions" />
<package name="imoen-default" extends="json-default">
<interceptors>
<!-- Default Stack -->
<interceptor-stack name="myStack">
<interceptor-ref name="defaultStack">
<param name="exception.logEnabled">true</param>
<param name="exception.logLevel">warn</param>
</interceptor-ref>
<interceptor-ref name="authCheck" />
</interceptor-stack>
<!-- Authority CheckInterceptor -->
<interceptor name="authCheck" class="my.PermissionCheckInterceptor" />
</interceptors>
<global-results>
<result name="error">/error.jsp</result>
<result name="login">/login.jsp</result>
<result name="access.deny">/access_deny.jsp</result>
<result name="teacher.deny">/teacher_deny.jsp</result>
<result name="404">/404.jsp</result>
<result name="500">/500.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping result="404"
exception="my.NoFoundException" />
<exception-mapping result="500"
exception="my.BusinessException" />
<exception-mapping result="error"
exception="java.lang.Throwable" />
</global-exception-mappings>
</package>
<!-- struts packages -->
<include file="struts/*.xml"></include>
</struts>