概述
前面两章收集了一些java 国际化相关api用法,以及spring MVC对国际化的支持。今天打算采用spring MVC搭建一套支持国际化的demo环境(采用的Spring MVC版本为:4.3.1.RELEASE),代码已经放到github,地址请见文章结尾。
主要整合内容包括:
1、view层采用的Freemaker。
2、使用自定义的formatter,对日期、货币等进行转化。
springMVC 相关配置
web.xml 配置:主要包含三部分,“Spring 容器的配置”、“Spring mvc 配置”、“spring 字符集处理配置”。完整的内容如下:
<web-app 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"> <display-name>locale-demo</display-name> <!-- step1 Spring 容器启动器 --> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- spring 容器配置 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-config.xml</param-value> </context-param> <!-- step2 Spring mvc 配置 --> <servlet> <servlet-name>springmvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> <!-- 程序启动时装在该servlet --> </servlet> <servlet-mapping> <servlet-name>springmvc</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <!-- step3 spring character encoding --> <filter> <filter-name>Character Encoding</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>Character Encoding</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
Spring容器对应的配置文件是:spring-config.xml ,SpringMVC对应的配置文件是spring-mvc.xml。spring-config.xml 可以手动配置bean、指定属性配置文件(.properties)、以及制定其他子配置文件,如:数据库配置文件、工具类配置文件、外部接口配置文件等。本次demo环境,只是整合框架,具体内容根据项目需要再添加。
spring-config.xml内容如下:
<?xml version="1.0" encoding="GBK"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd" default-autowire="byName"> <!-- 加载属性配置文件,主要为spring bean实例化 提供配置支持--> <bean id="propertyPlaceholder" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:spring-locale.properties</value> </list> </property> </bean> <!--导入其他所需的配置文件 --> <!-- <import resource="spring/*.xml" /> 配置文件尽量根据模块进行拆分--> </beans>
在手动注入bean时,往往我们需要一些配置参数,比如:数据库用户名、密码等,这些参数都可以提前配置到属性配置文件spring-locale.properties中。本次demo spring-locale.properties为空,根据业务需要添加。
SpringMVC对应的配置文件spring-mvc.xml,是本次讲解的重点。整合freemaker、以及国际化支持等都在该配置文件中体现,内容如下:
<?xml version="1.0" encoding="GBK"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd" default-autowire="byName"> <mvc:annotation-driven /> <mvc:default-servlet-handler /> <context:component-scan base-package="com.sky.locale.demo.controller" > <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/> </context:component-scan> <mvc:resources mapping="/css/**" location="/css/" /> <mvc:resources mapping="/*.html" location="/" /> <!-- Freemarker属性配置--> <bean id="freemarkerConfiguration" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="location" value="classpath:freemarker.properties"/> </bean> <bean id="fmXmlEscape" class="freemarker.template.utility.XmlEscape" /> <!-- Freemarker配置--> <bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> <property name="freemarkerSettings" ref="freemarkerConfiguration"/> <property name="templateLoaderPath"> <value>/WEB-INF/view/</value> </property> <property name="freemarkerVariables"> <map> <entry key="xml_escape" value-ref="fmXmlEscape" /> </map> </property> </bean> <!-- 配置freeMarker视图解析器 --> <bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.freemarker.FreeMarkerView"/> <property name="contentType" value="text/html; charset=utf-8"/> <property name="cache" value="false"/> <property name = "suffix" value = ".ftl"></property> <property name="exposeRequestAttributes" value="true" /> <property name="exposeSessionAttributes" value="true" /> <property name="exposeSpringMacroHelpers" value="true" /> <property name="requestContextAttribute" value="request"/> </bean> <!-- 图片上传 处理--> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="defaultEncoding" value="utf-8" /> <property name="maxUploadSize" value="10485760000" /> <property name="maxInMemorySize" value="40960" /> </bean> <!-- 国际化资源文件 --> <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <property name="basenames" > <list> <value>/WEB-INF/resource/usermsg</value> <value>/WEB-INF/resource/userlabels</value> </list> </property> <property name="defaultEncoding" value="UTF-8"/> </bean> <!-- 本地化配置 --> <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver"> <property name="cookieName" value="clientlanguage"/> <property name="cookieMaxAge" value="94608000"/> <property name="defaultLocale" value="en" /> </bean> <mvc:annotation-driven conversion-service="formatService" /> <!-- formatter转换配置 --> <bean id="formatService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean"> <property name="formatters"> <set> <!--<bean class="org.springframework.format.number.CurrencyStyleFormatter"> </bean> <bean class="org.springframework.format.number.NumberStyleFormatter"> </bean> <bean class="org.springframework.format.number.PercentStyleFormatter"> </bean> <bean class="org.springframework.format.datetime.DateFormatter"> </bean> --> <bean class="com.sky.locale.demo.formatter.MyDateFormatter" /> <bean class="com.sky.locale.demo.formatter.MyCurrencyFormatter" /> </set> </property> </bean> </beans>
这里主要说下与Freemaker整合的配置,其他关于国际化的配置说明可以参考上一章《java国际化之---springMVC(二)》。
首先看下Freemaker基础配置:
<!-- Freemarker配置--> <bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer"> <property name="freemarkerSettings" ref="freemarkerConfiguration"/> <property name="templateLoaderPath"> <value>/WEB-INF/view/</value> </property> <property name="freemarkerVariables"> <map> <entry key="xml_escape" value-ref="fmXmlEscape" /> </map> </property> </bean>
1、freemarkerSettings属性:设置FreeMarker启动属性配置,可以直接配置,也可以配置到属性文件,这次采用的后者。对应的属性配置为:
<!-- Freemarker属性配置--> <bean id="freemarkerConfiguration" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="location" value="classpath:freemarker.properties"/> </bean>
可以看到读取了属性配置文件freemarker.properties,再来看下中的内容:
#设置标签类型:square_bracket:[] auto_detect:[]<> tag_syntax=auto_detect #模版缓存时间,单位:秒 template_update_delay=0 default_encoding=UTF-8 output_encoding=UTF-8 locale=zh_CN #设置数字格式 ,防止出现 000.00 number_format=\# #变量为空时,不会报错 classic_compatible=true #这个表示每个freemarker的视图页面都会自动引入这个ftl文件。里面定议的就是一些宏,如text文本框,各种form元素 #auto_import="/WEB-INF/templates/index.ftl" as do auto_import="/common/spring.ftl" as spring
具体根据自己的需要调整,这里特别说下auto_import="/common/spring.ftl" as spring,spring.ftl是spring MVC针对Freemaker实现的宏,可以用来读取国际化配置信息等。该文件在spring-webmvc-4.3.1.RELEASE.jar中,具体路径如下:
将该文件copy到WEB-INF/common路径下,还可以根据自己需要修改和新增宏命令。
2、templateLoaderPath属性:配置Freemaker模板文件路径前缀,这里配置的/WEB-INF/view/,注意根目录别配置错了。Spring MVC还支持,多种视图一起使用,一般使用二级目录区分,比如:/WEB-INF/vm/对应velocity,/WEB-INF/jsp/ 对应原始jsp 等等。
3、freemarkerVariables属性:配置Freemaker的自定义标签,这里是个map结构,可以配置多个。
再来看下Freemaker的视图配置:
<!-- 配置freeMarker视图解析器 --> <bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.freemarker.FreeMarkerView"/> <property name="contentType" value="text/html; charset=utf-8"/> <property name="cache" value="false"/> <property name = "suffix" value = ".ftl"></property> <property name="exposeRequestAttributes" value="true" /> <property name="exposeSessionAttributes" value="true" /> <property name="exposeSpringMacroHelpers" value="true" /> <property name="requestContextAttribute" value="request"/> </bean>
如前面所说,你还可以配置多个视图解析器:jsp文件对应的InternalResourceViewResolver解析器,以及velocity对应的VelocityLayoutViewResolver视图解析器,并且Spring MVC允许你配置多个一起使用,根据不同的业务使用不同的视图解析器。
最终配置相关的目录结构如下:
国际化配置文件、以及Freemaker模板文件目录结构如下:
Spring相关配置就说这些吧,关于Freemaker模板文件后面讲解,下面来看看Controller。
Controller控制器代码
Controller相关的代码结构如下:
controller包中对应的是本实例的控制器存放目录,首先来看下UserController,主要处理4类请求:add、save、edit、changelanguage 分别对应:添加用户、保存用户、修改用户、修改语言。具体代码如下:
@Controller public class UserController { @RequestMapping(value="add") public String addUser(Model model) { model.addAttribute(new User()); return "/user/UserForm"; } @RequestMapping(value="save") public String saveUser(@ModelAttribute User user, BindingResult bindingResult, Model model) { UserValidator userValidator = new UserValidator(); userValidator.validate(user, bindingResult); if (bindingResult.hasErrors()) { FieldError fieldError = bindingResult.getFieldError(); System.out.println("Code:" + fieldError.getCode() + ", field:" + fieldError.getField()); return "/user/UserForm"; } // save product here model.addAttribute("org.springframework.validation.BindingResult.user",new BindException(bindingResult)); return "/user/UserInfo"; } /** * * @param model * @return */ @RequestMapping(value="edit") public String editUser(Model model) { //省略从数据库中查询代码 User user = new User(); user.setName("张三"); Date now = new Date(); user.setBirthday(now); user.setMoney(new BigDecimal("12.12")); model.addAttribute("user",user); return "/user/UserForm"; } @RequestMapping(value = "/changelanguage", method = RequestMethod.POST) public void changeLanguage(@RequestParam String new_lang,HttpServletRequest request, HttpServletResponse response) { String msg = ""; try { LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request); if (localeResolver == null) { throw new IllegalStateException("No LocaleResolver found: not in a DispatcherServlet request?"); } LocaleEditor localeEditor = new LocaleEditor(); localeEditor.setAsText(new_lang); localeResolver.setLocale(request, response, (Locale)localeEditor.getValue()); msg = "Change Language Success!"; } catch(Exception ex) { msg = "error"; ex.printStackTrace(); } response.setCharacterEncoding(CharEncoding.UTF_8); try { response.getWriter().print(msg); } catch (IOException e) { e.printStackTrace(); } } }
View视图
这里采用的是Freemaker视图,模板文件主要有两个:
首先看下UserForm.ftl(UserInfo.ftl文件内容不再累述):
<!DOCTYPE html> <html> <head> <title><@spring.message "page.user.title"/> </title> <link rel="stylesheet" href="/css/main.css"> </head> <body> <div id="global"> <@spring.message "current.locale"/> : ${request.locale} <br/> <@spring.message "select.language"/> : <span><a href="javascript:void(0)" onclick="changeLanguage('en_GB')">EN</a></span> |<span><a href="javascript:void(0)" onclick="changeLanguage('zh_CN')">CN</a></span> <form name="user" action="save" method="post"> <fieldset> <legend><@spring.message "user.form.name"/></legend> <p> <@spring.bind "user.name" /> <label for="name"><@spring.message "label.userName"/>:</label> <input id="name" type="text" name="name" value="${user.name}" cssErrorClass="error"/> <@spring.showErrors "<br/>" cssClass="error"/> </p> <p> <@spring.bind "user.birthday" /> <label for="birthday"><@spring.message "label.birthday"/>: </label> <input id="birthday" type="text" name="birthday" value="<#if (user.birthday)??> ${(user.birthday?datetime)} </#if>" cssErrorClass="error"/> <@spring.showErrors "<br/>" cssClass="error"/> </p> <p> <@spring.bind "user.money" /> <label for="money"><@spring.message "label.money"/>: </label> <input id="money" type="text" name="money" value="${(user.money?string.currency)!}" cssErrorClass="error"/> <@spring.showLastError classOrStyle="error"/> </p> <p id="buttons"> <input id="reset" type="reset" tabindex="4" value="<@spring.message "button.reset"/>"> <input id="submit" type="submit" tabindex="5" value="<@spring.message "button.submit"/>"> </p> </fieldset> </form> </div> </body> </html> <script type="text/javascript" src="//misc.360buyimg.com/jdf/lib/jquery-1.6.4.js?t=1705252218"></script> <script type="text/javascript"> function changeLanguage(language) { $.ajax({ type: "POST", url:"/changelanguage", data: "new_lang="+language, dataType:"text", async: true, error: function(data, error) {alert("change lang error!"); alert(error)}, success: function(data) { window.location.reload(); } }); } </script>
需要说明以下几点:
1、@spring.message,带有这个标记的标签,表面是本地化消息,这里会根据不同的语言选择不同的国际化配置文件,再根据不同的key选择不同的消息。
比如当前语言为cn_ZH(汉语_中国大陆),对应的配置文件为:usermsg_zh_CN.properties、userlabels_zh_CN.properties。<@spring.message "page.user.title"/>标签中,page.user.title对应的值在userlabels_zh_CN.properties中,配置为:page.user.title=新增用户,该位置的渲染结果即为:“新增用户”。配置文件中的内容,就不贴出来了,感兴趣的可以从文章结尾的github地址中下载。
2、@spring.bind、@spring.showErrors分别为绑定变量,和显示该变量的错误信息。连同1中的@spring.message 这三个标签都是在spring.ftl中定义的。
3、Freemaker国际化支持,${(user.birthday?datetime)}、${(user.money?string.currency)} 会根据不同的语言国家,做不同的格式显示。比如中国,货币显示为:¥12.12;英语英国,货币显示为:£12.12。
其他关于Freemaker的标签说明,参考其官方文档:http://freemarker.org/docs/ref_directive_local.html
日期、货币国际化处理
SpringMVC主要通过定义不同Formatter实现对日期、货币等国际化处理。 Springmvc 自带对日期、货币国际化处理Formatter实现,我们也可以根据自己业务定义自己的Formatter。
自定义的日期时间formatter,MyDateFormatter,调用其可以把String格式的日期转换为Date型,比如:可以把英文环境下的“Jun 13, 2017 9:40:57 PM”,以及中文环境下的” 2017-06-13 21:40:57” 转换为相同的Date,实现如下:
public class MyDateFormatter implements Formatter<Date> { @Override public Date parse(String s, Locale locale) throws ParseException{ DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, locale); System.out.println("parse"); try { return df.parse(s); } catch (ParseException e) { throw new IllegalArgumentException( "invalid date format."); } } @Override public String print(Date date, Locale locale) { DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, locale); System.out.println("format"); return df.format(date); } }
自定义的货币处理formatter,MyCurrencyFormatter,可以实现把不同国家带符号的价格转换为BigDecimal,实现如下:
public class MyCurrencyFormatter implements Formatter<BigDecimal> { /** * 去掉货币符号,并转换为BigDecimal * @param s * @param locale * @return * @throws ParseException */ @Override public BigDecimal parse(String s, Locale locale) throws ParseException { try { NumberFormat curF = NumberFormat.getCurrencyInstance(locale); BigDecimal bd = new BigDecimal(curF.parse(s).toString());//去掉货币符号 return bd; } catch (ParseException e) { //如果没有带单位 转换会失败,但是如果是数字可以成功转换成BigDecimal,主要是springMVC做了兼容处理 throw new IllegalArgumentException( "invalid Currency format."); } } /** * 把BigDecimal 转换为对应国家带货币单位的 字符串格式 * @param bigDecimal * @param locale * @return */ @Override public String print(BigDecimal bigDecimal, Locale locale) { NumberFormat curF = NumberFormat.getCurrencyInstance(locale); return curF.format(bigDecimal); } }
最后通过配置注入到Spring 容器中,当表单提交时就可以实现类型自动转换,配置如下:
<!-- formatter转换配置 -->
<bean id="formatService"
class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
<property name="formatters">
<set>
<!-- 使用SpringMVC 自带的formatters处理 日期、数字国际化 -->
<!--<bean class="org.springframework.format.number.CurrencyStyleFormatter">
</bean>
<bean class="org.springframework.format.number.NumberStyleFormatter">
</bean>
<bean class="org.springframework.format.number.PercentStyleFormatter">
</bean>
<bean class="org.springframework.format.datetime.DateFormatter">
</bean> -->
<bean class="com.sky.locale.demo.formatter.MyDateFormatter" />
<bean class="com.sky.locale.demo.formatter.MyCurrencyFormatter" />
</set>
</property>
</bean>
示例演示
以上实例demo代码,已经放到github:https://github.com/gantianxing/locale-demo.git,方便以后继续整合使用,也欢迎感兴趣的朋友下载。下载成功后,使用idea打开,打包即可运行。
启动成功后,首先访问http://localhost/add
访问:http://localhost/edit
修改相关数据后,点添加按钮,返回:
点击add页面的‘EN’,可以切换到英文版(ps:如果切换不成功,tomcat版本请换成tomcat8以上):
关于英文版的操作,就不再演示了。感兴趣的可以自己操作下,如有问题请指正,欢迎留言。
以上代码GitHub地址https://github.com/gantianxing/locale-demo.git。
相关推荐
在本项目中,我们主要探讨如何手动构建一个基于SpringMVC、Spring Data JPA、Hibernate以及FreeMarker模板引擎的Maven工程,同时实现环境切换功能。这个基础框架为日常开发工作提供了必要的支持。 首先,SpringMVC...
通过这个"SpringMVC+Freemaker Demo",你可以深入了解这两种技术的结合使用,以及它们如何协同工作来构建一个完整的Web应用。实际操作过程中,可以进一步学习异常处理、国际化、缓存等高级话题,提升自己的开发能力...
这个demo项目展示了如何将这些技术有效地集成,以实现数据持久化、模板渲染、权限管理以及日志记录等功能。接下来,我们将深入探讨这些关键组件及其在项目中的作用。 1. **SpringBoot**:SpringBoot是Spring框架的...
"SpringMVC集成Freemarker例子demo"是一个实际的项目示例,展示了如何在SpringMVC框架下配置和使用Freemarker。在这个例子中,你可能能看到如何配置SpringMVC的`freemarkerConfigurer`,设置模板路径,以及如何在...
内容概要:本文详细介绍了基于DSP28035的CAN在线升级程序及其Bootloader开发服务。主要内容涵盖CAN通讯协议的设计与实现,包括CAN模块初始化、Hex文件解析、内存分配以及应用程序跳转等关键技术点。此外,还讨论了上位机软件的开发选择和技术难点,如超时检测、CRC校验、中断向量表重映射等。文中不仅提供了具体的代码示例,还分享了许多实践经验,如避免内存越界、处理地址扩展等问题的方法。 适合人群:从事嵌入式系统开发的技术人员,尤其是那些对DSP28035感兴趣或正在使用该处理器进行项目的开发者。 使用场景及目标:适用于需要实现远程固件更新的嵌入式设备制造商,旨在提高产品维护效率并减少物理干预的需求。通过学习本文,读者可以掌握如何构建一个稳定可靠的CAN在线升级解决方案。 其他说明:文章强调了协议设计的重要性,并指出了一些常见的错误和陷阱,帮助读者避开这些问题。同时,作者还提到了一些优化技巧,比如利用DMA加速数据传输、合理规划内存布局等,以确保系统的高性能和稳定性。
内容概要:本文详细介绍了基于UDS(Unified Diagnostic Services)协议的Bootloader在Autosar架构下的定制开发过程。主要内容涵盖Autosar架构与DCM(诊断通信管理)模块的集成,以及针对不同系列芯片(如NXP S32K、Infineon TC275等)的具体实现细节。文中通过具体的代码示例展示了从初始化、诊断服务处理到跳转应用程序的全过程,并讨论了不同芯片之间的差异及其应对策略。此外,还涉及了存储器管理、数据传输优化和安全启动等方面的内容。 适合人群:从事汽车电子开发的专业人士,尤其是对Bootloader开发感兴趣的工程师和技术人员。 使用场景及目标:适用于需要深入了解和实现基于UDS协议的Bootloader定制项目的团队。主要目标是提高汽车电子系统的诊断效率和可靠性,同时确保不同芯片平台间的兼容性和性能最优化。 其他说明:文章不仅提供了理论指导,还包括大量实用的代码片段和实践经验分享,帮助读者更好地理解和应用于实际项目中。
内容概要:本文详细介绍了如何通过Modbus协议实现昆仑通态触摸屏与台达VFD-M系列变频器之间的通讯,具体涵盖了硬件接线、关键参数设置、MCGS组态环境中的设备配置、变量定义、界面设计及脚本编写等内容。文中不仅提供了详细的参数设置方法,还分享了一些常见的调试技巧和故障排查方法,如硬件接线注意事项、参数设置要点、通讯故障解决措施等。 适合人群:从事工业自动化领域的工程师和技术人员,尤其是那些需要进行触摸屏与变频器通讯集成工作的人员。 使用场景及目标:适用于需要通过触摸屏远程控制变频器的应用场景,如工厂自动化生产线、机械设备控制等。目标是让读者能够独立完成从硬件连接到软件编程的整个通讯系统搭建过程。 其他说明:文章强调了实际操作中的注意事项和容易忽视的细节,如硬件接线的特殊性、参数设置的准确性、通讯协议的具体应用等,有助于提高项目的成功率和稳定性。同时,提供了丰富的调试工具和方法,帮助读者快速定位和解决问题。
内容概要:本文详细介绍了一种750W高功率因数(PF)充电机电源方案,采用UCC28070、ST6599和PIC16F193X三款芯片组合。UCC28070用于功率因数校正(PFC),通过交错式升压电路提升PF值;ST6599负责LLC谐振变换器,确保高效功率转换;PIC16F193X作为微控制器进行智能控制。文中不仅提供了详细的原理图、设计文件和烧录程序,还分享了具体的应用代码和调试技巧。此外,引用了华南理工大学硕士学位论文,深入探讨了设计优化方法。 适合人群:电源设计工程师、电子工程专业学生、对高效电源设计感兴趣的开发者。 使用场景及目标:适用于需要高功率因数和高效能的充电机应用场景,如电动汽车充电桩、数据中心备用电源等。目标是帮助读者掌握高效电源设计的技术细节,提升产品性能。 其他说明:本文不仅提供了硬件设计思路,还包括软件编程实例,如PFC控制算法、LLC频率调整、故障保护机制等。同时强调了实际应用中的注意事项,如寄存器配置、元件选型、PCB布局等。
内容概要:本文详细介绍了基于200smart PLC和昆仑通态触摸屏构建的一拖三恒压供水系统的实现方法及其调试经验。主要内容涵盖系统架构设计、PID控制参数整定、触摸屏配置、水泵轮换逻辑以及常见的调试技巧和注意事项。文中强调了PID控制在变频器调度中的重要性,提供了具体的代码示例和技术细节,如PID输出限幅处理、Modbus通信映射、压力反馈处理等。此外,作者还分享了许多宝贵的实战经验和教训,如避免在触摸屏上进行复杂运算、确保硬件布局合理性等。 适合人群:从事自动化控制系统设计与调试的技术人员,尤其是对PID控制和PLC编程有一定基础的研发人员。 使用场景及目标:适用于需要精确控制供水压力的工业场合,如小区二次供水、厂房循环水系统等。目标是帮助技术人员理解和掌握一拖三恒压供水系统的实现方法,提高系统的稳定性和可靠性。 其他说明:文中提到的具体参数和代码片段可供参考,但在实际应用中需根据具体情况进行适当调整。
该资源为natsort-3.1.2.tar.gz,欢迎下载使用哦!
该资源为natsort-2.0.0-py2.7.egg,欢迎下载使用哦!
内容概要:本文详细阐述了DeepSeek大模型在服装行业的应用方案,旨在通过人工智能技术提升服装企业的运营效率和市场竞争力。文章首先介绍了服装行业的现状与挑战,指出传统模式难以应对复杂的市场变化。DeepSeek大模型凭借其强大的数据分析和模式识别能力,能够精准预测市场趋势、优化供应链管理、提升产品设计效率,并实现个性化推荐。具体应用场景包括设计灵感生成、自动化设计、虚拟试衣、需求预测、生产流程优化、精准营销、智能客服、用户体验提升等。此外,文章还探讨了数据安全与隐私保护的重要性,以及技术实施与集成的具体步骤。最后,文章展望了未来市场扩展和技术升级的方向,强调了持续优化和合作的重要性。 适用人群:服装行业的企业管理层、技术负责人、市场和销售团队、供应链管理人员。 使用场景及目标:①通过市场趋势预测和用户偏好分析,提升设计效率和产品创新;②优化供应链管理,减少库存积压和生产浪费;③实现精准营销,提高客户满意度和转化率;④通过智能客服和虚拟试衣技术,提升用户体验;⑤确保数据安全和隐私保护,建立用户信任。 阅读建议:此资源不仅涵盖技术实现的细节,还涉及业务流程的优化和管理策略的调整,建议读者结合实际业务需求,重点关注与自身工作相关的部分,并逐步推进技术的应用和创新。
内容概要:本文详细介绍了一套基于三菱FX3U PLC的完整开发方案,涵盖硬件设计和软件编程两个方面。硬件部分包括详细的原理图、PCB文件以及关键组件的选择和布局技巧,如电源模块、光耦隔离电路、继电器输出等。软件部分则涉及梯形图编程和C语言开发,展示了如何利用GX Works2进行梯形图编程,以及如何使用Keil进行C语言开发,实现复杂的控制逻辑和高效的任务调度。此外,还提供了许多调试技巧和注意事项,帮助开发者避免常见错误并提高开发效率。 适合人群:从事工业自动化领域的工程师和技术人员,尤其是对PLC开发感兴趣的初学者和有一定经验的研发人员。 使用场景及目标:适用于需要深入了解PLC底层运作机制、掌握硬件设计和软件编程技能的场合。目标是通过实际案例和详细指导,帮助读者快速上手三菱FX3U PLC的开发,实现高效的控制系统设计。 其他说明:文中提供的代码片段和设计思路不仅有助于理解PLC的工作原理,还可以作为实际项目的参考,加速开发进程。同时,文中还分享了许多实践经验,对于解决实际开发中的问题非常有帮助。
甲壳虫adb助手安全下载.apk
内容概要:本文详细介绍了基于SJA1000协议栈的FPGA实现CAN总线控制器的全过程。涵盖了Verilog和VHDL双版本源码、Altera和Xilinx平台的具体实现细节以及完整的testbench程序。文中深入探讨了状态机控制器、CRC校验器、位时序单元和FIFO缓存四大核心模块的设计思路和技术要点。同时,提供了详细的仿真验证方法和优化技巧,如随机延迟测试、时钟管理配置等。此外,还附带了Quartus II 13.0和ISE14.7的安装指南及常见问题解决方案。 适合人群:FPGA开发者、嵌入式系统工程师、电子工程专业学生及研究人员。 使用场景及目标:适用于希望深入了解CAN总线控制器硬件实现的技术人员,帮助他们快速掌握FPGA开发流程,完成从代码编写到仿真的全流程操作。目标是在实际项目中高效实现CAN总线通信功能,提升系统的稳定性和性能。 其他说明:本文不仅提供完整的工程代码和仿真工具,还包括详细的开发板引脚约束配置和跨平台移植指导,确保用户能够顺利进行开发和调试。
中兴光猫G7610V2-V3.0.0P1N12固件
流变学仿真方法:流变学仿真软件介绍.zip
内容概要:本文详细介绍了如何利用昆仑通态触摸屏与ABB变频器ACS510通过Modbus RTU协议实现直接通讯,构建高效的恒压供水系统。文中涵盖了硬件连接、参数设置、脚本编写、策略配置等方面的内容。通过这种方式,不仅简化了操作流程,还提高了系统的稳定性和可靠性。具体而言,文章首先解释了选择这两者的理由,接着逐步讲解了硬件接线方法、参数配置细节、脚本控制逻辑以及一些常见的调试技巧。此外,还特别提到了夜间降压逻辑、故障复位按钮等高级功能的应用。 适合人群:从事自动化控制系统设计、维护的技术人员,尤其是对恒压供水系统感兴趣的工程师。 使用场景及目标:适用于需要稳定水压供应的场合,如居民小区、商业建筑等。主要目标是通过简化操作流程、提高系统稳定性,从而实现更加智能和高效的供水管理。 其他说明:文章提供了大量实际案例和技术细节,帮助读者更好地理解和应用相关技术。同时,强调了硬件和软件相结合的重要性,分享了许多实用的经验和技巧。
内容概要:本文全面介绍了移动开发的相关知识,首先概述了移动开发的概念及其重要性,随后详细介绍了iOS和Android两大主流平台的开发语言、环境及工具,并涵盖了跨平台开发框架如React Native、Flutter等。接着列举了版本控制、构建自动化、UI设计及调试测试等常用工具。文章还提供了丰富的学习资源,包括官方文档、书籍和视频教程。此外,针对移动开发中常见的性能优化、兼容性、安全性和用户体验设计等问题进行了探讨,并通过社交、电商、健身追踪和地图导航等实际案例展示了不同应用场景的技术实现。最后推荐了一些适合初学者的项目,鼓励读者实践所学知识。; 适合人群:对移动开发感兴趣的初学者,以及希望深入了解移动开发技术的开发者。; 使用场景及目标:①了解iOS和Android平台的开发环境和技术栈;②掌握跨平台开发工具的选择与使用;③学习如何解决移动开发中的性能、兼容性、安全等常见问题;④通过实战案例掌握不同类型应用的核心技术实现。; 其他说明:移动开发是一个不断发展的领域,文中提到的技术和工具可能会随行业发展而更新,建议读者持续关注最新动态并不断学习新技能。