struts2配置静态资源代码详解

Struts2框架有两个核心配置文件:struts.xml和Struts2默认属性文件default.properties(在struts2-core-2.3.20.jar中)

default.properties可以通过自己在classpath下写一个struts.properties文件进行定制改写

为什么是struts.properties,这可以看org.apache.struts2.config下的DefaultSettings和PropertiesSettings源码

DefaultSettings.java

public DefaultSettings() {
    ArrayList<Settings> list = new ArrayList<Settings>();
    // stuts.properties, default.properties
    try {
      list.add(new PropertiesSettings("struts"));
    } catch (Exception e) {
      log.warn("DefaultSettings: Could not find or error in struts.properties", e);
    }

PropertiesSettings.java

public PropertiesSettings(String name) {
    URL settingsUrl = ClassLoaderUtil.getResource(name + ".properties", getClass());
    if (settingsUrl == null) {
      if (LOG.isDebugEnabled()) {
      LOG.debug(name + ".properties missing");
      }
      settings = new LocatableProperties();
      return;
    }

也可以把你想写在struts.properties的自定义配置写在struts.xml文件下<constant>节点中,java培训如果同时都在两个文件配置了,一个相同的项目, 先加载 struts.xml,再加载struts.properties也就是说 struts.properties 是可以覆盖 struts.xml里面的配置的

<constant name="struts.devMode" value="false" />
  <constant name="struts.i18n.encoding" value="UTF-8" />
  <constant name="struts.action.extension" value="action," />
  <constant name="struts.objectFactory" value="spring" />
  <constant name="struts.custom.i18n.resources" value="ApplicationResources,errors" />
  <constant name="struts.multipart.maxSize" value="2097152" />
  <constant name="struts.ui.theme" value="css_xhtml" />
  <constant name="struts.codebehind.pathPrefix" value="/WEB-INF/pages/" />
  <constant name="struts.enable.SlashesInActionNames" value="true" />
  <constant name="struts.convention.action.disableScanning"
    value="true" />
  <constant name="struts.mapper.alwaysSelectFullNamespace"
    value="false" />
  <!-- Allow <s:submit> to call method names directly -->
  <constant name="struts.enable.DynamicMethodInvocation" value="true" />
  <constant name="struts.multipart.saveDir" value="/tmp"></constant>

在strut源码StrutsConstants.class包含了所有可配置项

package org.apache.struts2;
import org.apache.struts2.dispatcher.mapper.CompositeActionMapper;
/**
 * This class provides a central location for framework configuration keys
 * used to retrieve and store Struts configuration settings.
 */
public final class StrutsConstants {
  /** Whether Struts is in development mode or not */
  public static final String STRUTS_DEVMODE = "struts.devMode";
  /** Whether the localization messages should automatically be reloaded */
  public static final String STRUTS_I18N_RELOAD = "struts.i18n.reload";
  /** The encoding to use for localization messages */
  public static final String STRUTS_I18N_ENCODING = "struts.i18n.encoding";
  /** Whether to reload the XML configuration or not */
  public static final String STRUTS_CONFIGURATION_XML_RELOAD = "struts.configuration.xml.reload";
  /** The URL extension to use to determine if the request is meant for a Struts action */
  public static final String STRUTS_ACTION_EXTENSION = "struts.action.extension";
  /** Comma separated list of patterns (java.util.regex.Pattern) to be excluded from Struts2-processing */
  public static final String STRUTS_ACTION_EXCLUDE_PATTERN = "struts.action.excludePattern";
  /** Whether to use the alterative syntax for the tags or not */
  public static final String STRUTS_TAG_ALTSYNTAX = "struts.tag.altSyntax";
  /** The HTTP port used by Struts URLs */
  public static final String STRUTS_URL_HTTP_PORT = "struts.url.http.port";
  /** The HTTPS port used by Struts URLs */
  public static final String STRUTS_URL_HTTPS_PORT = "struts.url.https.port";
  /** The default includeParams method to generate Struts URLs */
  public static final String STRUTS_URL_INCLUDEPARAMS = "struts.url.includeParams";
  public static final String STRUTS_URL_RENDERER = "struts.urlRenderer";
  /** The com.opensymphony.xwork2.ObjectFactory implementation class */
  public static final String STRUTS_OBJECTFACTORY = "struts.objectFactory";
  public static final String STRUTS_OBJECTFACTORY_ACTIONFACTORY = "struts.objectFactory.actionFactory";
  public static final String STRUTS_OBJECTFACTORY_RESULTFACTORY = "struts.objectFactory.resultFactory";
  public static final String STRUTS_OBJECTFACTORY_CONVERTERFACTORY = "struts.objectFactory.converterFactory";
  public static final String STRUTS_OBJECTFACTORY_INTERCEPTORFACTORY = "struts.objectFactory.interceptorFactory";
  public static final String STRUTS_OBJECTFACTORY_VALIDATORFACTORY = "struts.objectFactory.validatorFactory";
  public static final String STRUTS_OBJECTFACTORY_UNKNOWNHANDLERFACTORY = "struts.objectFactory.unknownHandlerFactory";
  /** The com.opensymphony.xwork2.util.FileManager implementation class */
  public static final String STRUTS_FILE_MANAGER_FACTORY = "struts.fileManagerFactory";
  /** The com.opensymphony.xwork2.util.fs.FileManager implementation class */
  public static final String STRUTS_FILE_MANAGER = "struts.fileManager";
  /** The com.opensymphony.xwork2.util.ObjectTypeDeterminer implementation class */
  public static final String STRUTS_OBJECTTYPEDETERMINER = "struts.objectTypeDeterminer";
  /** The package containing actions that use Rife continuations */
  public static final String STRUTS_CONTINUATIONS_PACKAGE = "struts.continuations.package";
  /** The org.apache.struts2.config.Configuration implementation class */
  public static final String STRUTS_CONFIGURATION = "struts.configuration";
  /** The default locale for the Struts application */
  public static final String STRUTS_LOCALE = "struts.locale";
  /** Whether to use a Servlet request parameter workaround necessary for some versions of WebLogic */
  public static final String STRUTS_DISPATCHER_PARAMETERSWORKAROUND = "struts.dispatcher.parametersWorkaround";
  /** The org.apache.struts2.views.freemarker.FreemarkerManager implementation class */
  public static final String STRUTS_FREEMARKER_MANAGER_CLASSNAME = "struts.freemarker.manager.classname";
  @Deprecated
  /** Cache Freemarker templates, this cache is managed by struts2,instead of native freemarker cache,set STRUTS_FREEMARKER_MRU_MAX_STRONG_SIZE >0&&STRUTS_FREEMARKER_TEMPLATES_CACHE_UPDATE_DELAY>0*/
  public static final String STRUTS_FREEMARKER_TEMPLATES_CACHE = "struts.freemarker.templatesCache";
  /** Update freemarker templates cache in seconds*/
  public static final String STRUTS_FREEMARKER_TEMPLATES_CACHE_UPDATE_DELAY = "struts.freemarker.templatesCache.updateDelay";
  /** Cache model instances at BeanWrapper level */
  public static final String STRUTS_FREEMARKER_BEANWRAPPER_CACHE = "struts.freemarker.beanwrapperCache";
  /** Maximum strong sizing for MruCacheStorage for freemarker */
  public static final String STRUTS_FREEMARKER_MRU_MAX_STRONG_SIZE = "struts.freemarker.mru.max.strong.size";
  /** org.apache.struts2.views.velocity.VelocityManager implementation class */
  public static final String STRUTS_VELOCITY_MANAGER_CLASSNAME = "struts.velocity.manager.classname";
  /** The Velocity configuration file path */
  public static final String STRUTS_VELOCITY_CONFIGFILE = "struts.velocity.configfile";
  /** The location of the Velocity toolbox */
  public static final String STRUTS_VELOCITY_TOOLBOXLOCATION = "struts.velocity.toolboxlocation";
  /** List of Velocity context names */
  public static final String STRUTS_VELOCITY_CONTEXTS = "struts.velocity.contexts";
  /** The directory containing UI templates. All templates must reside in this directory. */
  public static final String STRUTS_UI_TEMPLATEDIR = "struts.ui.templateDir";
  /** The default UI template theme */
  public static final String STRUTS_UI_THEME = "struts.ui.theme";
  /** Token to use to indicate start of theme to be expanded. */
  public static final String STRUTS_UI_THEME_EXPANSION_TOKEN = "struts.ui.theme.expansion.token";
  /** The maximize size of a multipart request (file upload) */
  public static final String STRUTS_MULTIPART_MAXSIZE = "struts.multipart.maxSize";
  /** The directory to use for storing uploaded files */
  public static final String STRUTS_MULTIPART_SAVEDIR = "struts.multipart.saveDir";
  /** Declares the buffer size to be used during streaming multipart content to disk. Used only with {@link org.apache.struts2.dispatcher.multipart.JakartaStreamMultiPartRequest} */
  public static final String STRUTS_MULTIPART_BUFFERSIZE = "struts.multipart.bufferSize";
  /**
   * The org.apache.struts2.dispatcher.multipart.MultiPartRequest parser implementation
   * for a multipart request (file upload)
   */
  public static final String STRUTS_MULTIPART_PARSER = "struts.multipart.parser";
  /** How Spring should autowire. Valid values are 'name', 'type', 'auto', and 'constructor' */
  public static final String STRUTS_OBJECTFACTORY_SPRING_AUTOWIRE = "struts.objectFactory.spring.autoWire";
  /** Whether the autowire strategy chosen by STRUTS_OBJECTFACTORY_SPRING_AUTOWIRE is always respected. Defaults
   * to false, which is the legacy behavior that tries to determine the best strategy for the situation.
   * @since 2.1.3
   */
  public static final String STRUTS_OBJECTFACTORY_SPRING_AUTOWIRE_ALWAYS_RESPECT = "struts.objectFactory.spring.autoWire.alwaysRespect";
  /** Whether Spring should use its class cache or not */
  public static final String STRUTS_OBJECTFACTORY_SPRING_USE_CLASS_CACHE = "struts.objectFactory.spring.useClassCache";
  /** Uses different logic to construct beans, see https://issues.apache.org/jira/browse/WW-4110 */
  public static final String STRUTS_OBJECTFACTORY_SPRING_ENABLE_AOP_SUPPORT = "struts.objectFactory.spring.enableAopSupport";
  /** Whether or not XSLT templates should not be cached */
  public static final String STRUTS_XSLT_NOCACHE = "struts.xslt.nocache";
  /** Location of additional configuration properties files to load */
  public static final String STRUTS_CUSTOM_PROPERTIES = "struts.custom.properties";
  /** Location of additional localization properties files to load */
  public static final String STRUTS_CUSTOM_I18N_RESOURCES = "struts.custom.i18n.resources";
  /** The org.apache.struts2.dispatcher.mapper.ActionMapper implementation class */
  public static final String STRUTS_MAPPER_CLASS = "struts.mapper.class";
  /**
   * A prefix based action mapper that is capable of delegating to other
   * {@link org.apache.struts2.dispatcher.mapper.ActionMapper}s based on the request's prefix
   * You can specify different prefixes that will be handled by different mappers
   */
  public static final String PREFIX_BASED_MAPPER_CONFIGURATION = "struts.mapper.prefixMapping";
  /** Whether the Struts filter should serve static content or not */
  public static final String STRUTS_SERVE_STATIC_CONTENT = "struts.serve.static";
  /** If static content served by the Struts filter should set browser caching header properties or not */
  public static final String STRUTS_SERVE_STATIC_BROWSER_CACHE = "struts.serve.static.browserCache";
  /** Allows one to disable dynamic method invocation from the URL */
  public static final String STRUTS_ENABLE_DYNAMIC_METHOD_INVOCATION = "struts.enable.DynamicMethodInvocation";
  /** Whether slashes in action names are allowed or not */
  public static final String STRUTS_ENABLE_SLASHES_IN_ACTION_NAMES = "struts.enable.SlashesInActionNames";
  /** Prefix used by {@link CompositeActionMapper} to identify its containing {@link org.apache.struts2.dispatcher.mapper.ActionMapper} class. */
  public static final String STRUTS_MAPPER_COMPOSITE = "struts.mapper.composite";
  public static final String STRUTS_ACTIONPROXYFACTORY = "struts.actionProxyFactory";
  public static final String STRUTS_FREEMARKER_WRAPPER_ALT_MAP = "struts.freemarker.wrapper.altMap";
  /** The name of the xwork converter implementation */
  public static final String STRUTS_XWORKCONVERTER = "struts.xworkConverter";
  public static final String STRUTS_ALWAYS_SELECT_FULL_NAMESPACE = "struts.mapper.alwaysSelectFullNamespace";
  /** XWork default text provider */
  public static final String STRUTS_XWORKTEXTPROVIDER = "struts.xworkTextProvider";
  /** The {@link com.opensymphony.xwork2.LocaleProvider} implementation class */
  public static final String STRUTS_LOCALE_PROVIDER = "struts.localeProvider";
  /** The name of the parameter to create when mapping an id (used by some action mappers) */
  public static final String STRUTS_ID_PARAMETER_NAME = "struts.mapper.idParameterName";
  /** The name of the parameter to determine whether static method access will be allowed in OGNL expressions or not */
  public static final String STRUTS_ALLOW_STATIC_METHOD_ACCESS = "struts.ognl.allowStaticMethodAccess";
  /** The com.opensymphony.xwork2.validator.ActionValidatorManager implementation class */
  public static final String STRUTS_ACTIONVALIDATORMANAGER = "struts.actionValidatorManager";
  /** The {@link com.opensymphony.xwork2.util.ValueStackFactory} implementation class */
  public static final String STRUTS_VALUESTACKFACTORY = "struts.valueStackFactory";
  /** The {@link com.opensymphony.xwork2.util.reflection.ReflectionProvider} implementation class */
  public static final String STRUTS_REFLECTIONPROVIDER = "struts.reflectionProvider";
  /** The {@link com.opensymphony.xwork2.util.reflection.ReflectionContextFactory} implementation class */
  public static final String STRUTS_REFLECTIONCONTEXTFACTORY = "struts.reflectionContextFactory";
  /** The {@link com.opensymphony.xwork2.util.PatternMatcher} implementation class */
  public static final String STRUTS_PATTERNMATCHER = "struts.patternMatcher";
  /** The {@link org.apache.struts2.dispatcher.StaticContentLoader} implementation class */
  public static final String STRUTS_STATIC_CONTENT_LOADER = "struts.staticContentLoader";
  /** The {@link com.opensymphony.xwork2.UnknownHandlerManager} implementation class */
  public static final String STRUTS_UNKNOWN_HANDLER_MANAGER = "struts.unknownHandlerManager";
  /** Throw RuntimeException when a property is not found, or the evaluation of the espression fails*/
  public static final String STRUTS_EL_THROW_EXCEPTION = "struts.el.throwExceptionOnFailure";
  /** Logs properties that are not found (very verbose) **/
  public static final String STRUTS_LOG_MISSING_PROPERTIES = "struts.ognl.logMissingProperties";
  /** Enables caching of parsed OGNL expressions **/
  public static final String STRUTS_ENABLE_OGNL_EXPRESSION_CACHE = "struts.ognl.enableExpressionCache";
  /** Enables evaluation of OGNL expressions **/
  public static final String STRUTS_ENABLE_OGNL_EVAL_EXPRESSION = "struts.ognl.enableOGNLEvalExpression";
  /** Disables {@link org.apache.struts2.dispatcher.StrutsRequestWrapper} request attribute value stack lookup (JSTL accessibility) **/
  public static final String STRUTS_DISABLE_REQUEST_ATTRIBUTE_VALUE_STACK_LOOKUP = "struts.disableRequestAttributeValueStackLookup";
  /** The{@link org.apache.struts2.views.util.UrlHelper} implementation class **/
  public static final String STRUTS_URL_HELPER = "struts.view.urlHelper";
  /** {@link com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter} **/
  public static final String STRUTS_CONVERTER_COLLECTION = "struts.converter.collection";
  public static final String STRUTS_CONVERTER_ARRAY = "struts.converter.array";
  public static final String STRUTS_CONVERTER_DATE = "struts.converter.date";
  public static final String STRUTS_CONVERTER_NUMBER = "struts.converter.number";
  public static final String STRUTS_CONVERTER_STRING = "struts.converter.string";
  /** Enable handling exceptions by Dispatcher - true by default **/
  public static final String STRUTS_HANDLE_EXCEPTION = "struts.handle.exception";
  public static final String STRUTS_CONVERTER_PROPERTIES_PROCESSOR = "struts.converter.properties.processor";
  public static final String STRUTS_CONVERTER_FILE_PROCESSOR = "struts.converter.file.processor";
  public static final String STRUTS_CONVERTER_ANNOTATION_PROCESSOR = "struts.converter.annotation.processor";
  public static final String STRUTS_CONVERTER_CREATOR = "struts.converter.creator";
  public static final String STRUTS_CONVERTER_HOLDER = "struts..converter.holder";
  public static final String STRUTS_EXPRESSION_PARSER = "struts.expression.parser";
  /** actions names' whitelist **/
  public static final String STRUTS_ALLOWED_ACTION_NAMES = "struts.allowed.action.names";
  /** enables action: prefix **/
  public static final String STRUTS_MAPPER_ACTION_PREFIX_ENABLED = "struts.mapper.action.prefix.enabled";
  /** enables access to actions in other namespaces than current with action: prefix **/
  public static final String STRUTS_MAPPER_ACTION_PREFIX_CROSSNAMESPACES = "struts.mapper.action.prefix.crossNamespaces";
  public static final String DEFAULT_TEMPLATE_TYPE_CONFIG_KEY = "struts.ui.templateSuffix";
  /** Allows override default DispatcherErrorHandler **/
  public static final String STRUTS_DISPATCHER_ERROR_HANDLER = "struts.dispatcher.errorHandler";
  /** Comma delimited set of excluded classes and package names which cannot be accessed via expressions **/
  public static final String STRUTS_EXCLUDED_CLASSES = "struts.excludedClasses";
  public static final String STRUTS_EXCLUDED_PACKAGE_NAME_PATTERNS = "struts.excludedPackageNamePatterns";
  /** Dedicated services to check if passed string is excluded/accepted **/
  public static final String STRUTS_EXCLUDED_PATTERNS_CHECKER = "struts.excludedPatterns.checker";
  public static final String STRUTS_ACCEPTED_PATTERNS_CHECKER = "struts.acceptedPatterns.checker";
  /** Constant is used to override framework's default excluded patterns **/
  public static final String STRUTS_OVERRIDE_EXCLUDED_PATTERNS = "struts.override.excludedPatterns";
  public static final String STRUTS_OVERRIDE_ACCEPTED_PATTERNS = "struts.override.acceptedPatterns";
  public static final String STRUTS_ADDITIONAL_EXCLUDED_PATTERNS = "struts.additional.excludedPatterns";
  public static final String STRUTS_ADDITIONAL_ACCEPTED_PATTERNS = "struts.additional.acceptedPatterns";
}

其中

/** Comma separated list of patterns (java.util.regex.Pattern) to be excluded from Struts2-processing */
  public static final String STRUTS_ACTION_EXCLUDE_PATTERN = "struts.action.excludePattern";

保存了不由struts2处理的路径,我们在struts.properties或者struts.xml中配置即可.

struts.action.excludePattern=/dwr/.*,/dwr/test/.*

正则表达式,并非URL匹配地址

总结

以上就是本文关于struts2配置静态资源代码详解的全部内容,希望对大家有所帮助。感兴趣的朋友可以参阅:struts2静态资源映射代码示例   Struts2 通过ognl表达式实现投影   Struts2修改上传文件大小限制方法解析 等,有什么问题可以随时留言,小编会及时回复大家的。感谢朋友们对本站的支持。

(0)

相关推荐

  • struts2开发流程及详细配置

    一:Struts开发步骤: 1. web项目,引入struts - jar包 2. web.xml中,引入struts的核心功能 配置过滤器 3. 开发action 4. 配置action src/struts.xml 二:详细配置    1.引入8个jar文件 commons-fileupload-1.2.2.jar   [文件上传相关包] commons-io-2.0.1.jar struts2-core-2.3.4.1.jar           [struts2核心功能包] xwork-

  • Struts2学习笔记(9)-Result配置全局结果集

    Result可以设定全局结果集,如: <struts> <constant name="struts.devMode" value="true" /> <package name="user" namespace="/user" extends="struts-default"> <global-results> <result name="m

  • 实例详解java Struts2的配置与简单案例

    Struts2的配置与简单案例: 1. 创建一个dynamic web project(创建时让它自动生成web.xml文件) 2.引入相关jar包 3.在web.xml中进行配置 (启动tomcat服务器之后第一个加载的文件就是web.xml) 在配置中添加过滤器: <filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.ng.filte

  • Struts2开发 基本配置与类型转换

    一.Action配置中的各项默认值 <package name="csdn" namespace="/test" extends="struts-default">        <action name="helloworld" class="cn.csdn.action.HelloWorldAction" method="execute" > <resu

  • struts2中常用constant命令配置方法

    struts.objectFactory这个属性用 于说明Struts2的 对象池创建工厂,Struts2也有自己的对象池,就像Spring那样,在配置文件中你可以引用对象池中的对象,你可以借助于Spring中的对象池, 当想要得到Spring中的对象池时,申明struts.objectFactory为Spring的对象池构建工厂.... struts.serve.static.browserCache 该属性设置浏览器是否缓存静态内容.当应用处于开发阶段时,我们希望每次请求都获得服务器的最新响

  • 详解在Java的Struts2框架中配置Action的方法

    在Struts2中Action部分,也就是Controller层采用了低侵入的方式.为什么这么说?这是因为在Struts2中action类并不需要继承任何的基类,或实现任何的接口,更没有与Servlet的API直接耦合.它通常更像一个普通的POJO(通常应该包含一个无参数的execute方法),而且可以在内容定义一系列的方法(无参方法),并可以通过配置的方式,把每一个方法都当作一个独立的action来使用,从而实现代码复用. 例如: package example; public class U

  • struts2配置静态资源代码详解

    Struts2框架有两个核心配置文件:struts.xml和Struts2默认属性文件default.properties(在struts2-core-2.3.20.jar中) default.properties可以通过自己在classpath下写一个struts.properties文件进行定制改写 为什么是struts.properties,这可以看org.apache.struts2.config下的DefaultSettings和PropertiesSettings源码 Default

  • springboot ehcache 配置使用方法代码详解

    EhCache是一个比较成熟的Java缓存框架,最早从hibernate发展而来, 是进程中的缓存系统,它提供了用内存,磁盘文件存储,以及分布式存储方式等多种灵活的cache管理方案,快速简单. Springboot对ehcache的使用非常支持,所以在Springboot中只需做些配置就可使用,且使用方式也简易. 下面通过本文给大家介绍springboot ehcache 配置使用方法,具体内容如下所示: 1. pom 引入依赖 <!-- Ehcache --> <dependency

  • Spring Boot2.0实现静态资源版本控制详解

    写在最前面 犹记毕业第一年时,公司每次发布完成后,都会在一个群里通知[版本更新,各部门清理缓存,有问题及时反馈]之类的话.归根结底就是资源缓存的问题,浏览器会将请求到的静态资源,如JS.CSS等文件缓存到用户本地,当用户再次访问时就不需要再次请求这些资源了,以此也是提升了用户体验.但是也正是因为这些资源缓存,导致客户端的静态文件往往不是当前最新版本.后来有同事增加了时间戳.随机数等,确实这也解决了客户端缓存的问题,但是却又带来了新的麻烦,导致每次访问都要请求服务器,无形中增加了服务器的压力. 那

  • ASP.NET Core缓存静态资源示例详解

    背景 缓存样式表,JavaScript或图像文件等静态资源可以提高您网站的性能.在客户端,总是从缓存中加载一个静态文件,这样可以减少对服务器的请求数量,从而减少获取页面及其资源的时间.在服务器端,由于它们的请求较少,服务器可以处理更多的客户端而无需升级硬件. 虽然缓存是一件好事,但您必须确保客户端始终运行最新版本的应用程序.当您部署下一个版本的网站时,您不希望客户端使用过时的缓存版本的文件. 方案: 为确保用户始终使用最新版本的文件,我们必须为每个文件版本提供一个唯一的URL.有很多策略: 使用

  • vmware虚拟机NAT配置静态IP教程详解

    一.配置虚拟机的"虚拟网络编辑器" 注意1:虚拟机局域网IP段一定不要和真实使用的IP段冲突. 二.查看本地电脑VMnet8网卡的IP段 注意2.本地电脑VMnet8网卡IP段必须与虚拟机局域网Ip端相同 三.更改虚拟机系统网卡的IP配置 vim /et/sysconfig/network-scripts/ifcfg-etho 修改为 BOOTPROTO="static" #dhcp改为static ONBOOT="yes" #开机启用本配置 I

  • Spring静态代理和动态代理代码详解

    本节要点: Java静态代理 Jdk动态代理 1 面向对象设计思想遇到的问题 在传统OOP编程里以对象为核心,并通过对象之间的协作来形成一个完整的软件功能,由于对象可以继承,因此我们可以把具有相同功能或相同特征的属性抽象到一个层次分明的类结构体系中.随着软件规范的不断扩大,专业化分工越来越系列,以及OOP应用实践的不断增多,随之也暴露了一些OOP无法很好解决的问题. 现在假设系统中有三段完全相似的代码,这些代码通常会采用"复制"."粘贴"方式来完成,通过这种方式开发

  • struts2入门(搭建环境、配置、示例)详解

    在慕课网学习struts2入门课程,在官网下载的最新的struts-2.5.5-all.zip,JDK使用的是jdk1.6,Tomcat9.0,一直报错[java.lang.UnsupportedClassVersionError],版本不一致,可是各种换版本也都不好使,无奈最后找到了一篇较新的博文,按照他的Struts2版本进行了配置,终于可以用了. ------不过还是不太明白为啥struts-2.5.5无论是配jdk1.6还是jdk1.8,还是更换tomcat版本,都不好用.有明白清楚的还

  • python静态web服务器实现方法及代码详解

    1.编写TCP服务器程序. 2.获取浏览器发送的http请求消息数据. 3.读取固定的页面数据,将页面数据组装成HTTP响应消息数据并发送给浏览器. 4.HTTP响应报文数据发送完成后,关闭服务于客户端的套接字. 实例 # 时间: 2021/10/21 20:38 import socket if __name__ == '__main__': # 创建tcp服务端套接字 tcp_server_socket = socket.socket(socket.AF_INET, socket.SOCK_

  • spring boot application properties配置实例代码详解

    废话不多说了,直接给大家贴代码了,具体代码如下所示: # =================================================================== # COMMON SPRING BOOT PROPERTIES # # This sample file is provided as a guideline. Do NOT copy it in its # entirety to your own application. ^^^ # ========

  • Java的静态类型检查示例代码详解

    关于静态类型检查和动态类型检查的解释: 静态类型检查:基于程序的源代码来验证类型安全的过程: 动态类型检查:在程序运行期间验证类型安全的过程: Java使用静态类型检查在编译期间分析程序,确保没有类型错误.基本的思想是不要让类型错误在运行期间发生. 在各色各样的编程语言中,总共存在着两个类型检查机制:静态类型检查和动态类型检查. 静态类型检查是指通过对应用程序的源码进行分析,在编译期间就保证程序的类型安全. 动态类型检查是在程序的运行过程中,验证程序的类型安全.在Java中,编译期间使用静态类型

随机推荐