首页 文章 精选 留言 我的

精选列表

搜索[接口文档],共10000篇文章
优秀的个人博客,低调大师

Spring 框架文档之 Web —— Servlet 技术栈

Spring Web MVC DispatcherServlet 使用 Java 配置或 web.xml 根据 Servlet 规范进行声明和映射。 然后使用 Spring 配置来发现请求映射、视图解析、异常处理等所需的委托组件。 Servlet 配置 public class MyWebApplicationInitializer implements WebApplicationInitializer { @Override public void onStartup(ServletContext servletCxt) { // Load Spring web application configuration AnnotationConfigWebApplicationContext ac = new AnnotationConfigWebApplicationContext(); ac.register(AppConfig.class); ac.refresh(); // 注册并初始化 DispatcherServlet DispatcherServlet servlet = new DispatcherServlet(ac); ServletRegistration.Dynamic registration = servletCxt.addServlet("app", servlet); registration.setLoadOnStartup(1); registration.addMapping("/app/*"); } } 或者 public class MyWebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { @Override protected Class<?>[] getRootConfigClasses() { return new Class<?>[] { RootConfig.class };//没有用 null 代替 } @Override protected Class<?>[] getServletConfigClasses() { return new Class<?>[] { App1Config.class }; } @Override protected String[] getServletMappings() { return new String[] { "/app1/*" }; } @Override protected void customizeRegistration(Dynamic registration) { registration.setInitParameter("enableLoggingRequestDetails", "true"); } } 处理过程 在请求中搜索 WebApplicationContext 并将其绑定为控制器和流程中的其他元素可以使用的属性 将语言环境解析器绑定到请求,以便让流程中的元素解析处理请求时使用的语言环境(呈现视图、准备数据等) 主题解析器被绑定到让视图等元素决定使用哪个主题的请求 如果指定了 multipart 文件解析器,将检查请求的 multipart。找到则将请求封装在 MultipartHttpServletRequest中 搜索适当的处理程序。找到则执行与处理程序(预处理程序、后处理程序和控制器)相关联的执行链,以便准备模型或呈现 如果是返回模型,则呈现视图。如果没有返回模型,则不会呈现视图,因为请求已经被执行了 特殊 Bean HandlerMapping —— 将请求映射到带有前置和后置拦截器的处理程序。细节 主要实现者 RequestMappingHandlerMapping 和 BeanNameUrlHandlerMapping 拦截器实现 HandlerInterceptor 的方法 preHandle(..): 在处理程序之前执行 postHandle(..): 在处理程序之后执行 afterCompletion(..): 在请求完成之后执行 public interface HandlerMapping { /** * 将 HttpServletRequest 映射到 Handler,并将匹配的 HandlerInterceptor 绑定到 HandlerExecutionChain */ HandlerExecutionChain getHandler(HttpServletRequest request) throws Exception; } public class HandlerExecutionChain { private final Object handler; private HandlerInterceptor[] interceptors; } HandlerAdapter —— 辅助 DispatcherServlet 调用映射到请求的处理程序。控制 public interface HandlerAdapter { /** * 使用给定 handler 处理请求,返回模型数据和视图名字封装的 ModelAndView */ ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception; } /** * 字符和 Map 封装成的对象 */ public class ModelAndView { private Object view; private ModelMap model; } ViewResolver —— 将从处理程序返回的字符串视图名称解析为要呈现给响应的实际视图 InternalResourceViewResolver —— 将视图解析为 Web 应用的内部资源 UrlBasedViewResolver —— 直接根据视图的名称解析视图 ContentNegotiatingViewResolver —— 根据请求文件名或 Accept 标头解析视图 FreeMarkerViewResolver —— 将视图解析为 FreeMarker 模板 ResourceBundleViewResolver —— 将视图解析为资源属性文件 AbstractCachingViewResolver —— 抽象的视图解析器类,提供了缓存视图的功能 public interface ViewResolver { /** * 根据指定的视图名称解析返回 */ View resolveViewName(String viewName, Locale locale) throws Exception; } public interface View { /** * 根据指定的模型数据渲染视图 */ void render(@Nullable Map<String, ?> model, HttpServletRequest request, HttpServletResponse response) throws Exception; } HandlerExceptionResolver —— 解析异常的策略,可能将异常映射到处理程序、HTML 错误视图或其他目标 SimpleMappingExceptionResolver —— 异常类名称和错误视图名称间的映射 DefaultHandlerExceptionResolver —— 解析 Spring MVC 引发的异常,并将它们映射到 HTTP 状态代码 ResponseStatusExceptionResolver —— 使用 @ResponseStatus 解析异常,并将它们映射到指定 HTTP 状态代码 ExceptionHandlerExceptionResolver —— 在 @Controller 或 @ControllerAdvice 类调用 @ExceptionHandler 解析异常 @RestController public class ErrorController { @RequestMapping(path = "/error") public Map<String, Object> handle(HttpServletRequest request) { Map<String, Object> map = new HashMap<String, Object>(); map.put("status", request.getAttribute("javax.servlet.error.status_code")); map.put("reason", request.getAttribute("javax.servlet.error.message")); return map; } } LocaleResolver —— 提供国际化的视图,解析客户端本地环境 ThemeResolver —— 提供个性化的布局,解析 web 应用程序可以使用的主题 MultipartResolver —— 提供表单文件上传,解析 multi-part 请求 注解 Controller 声明配置 —— 激活 @Controller 的自动检测 @Configuration @ComponentScan("org.example.web") public class WebConfig { // ... } 请求映射 —— @RequestMapping 完成请求到 Controller 方法的映射 变种:@GetMapping、@PostMapping、@PutMapping、@DeleteMapping、@PatchMapping 通过 @PathVariable 访问 URI 变量(支持置于类和方法上) {varName:regex} 使用正则表达式声明 URI 变量 consumes 指定请求的 Content-Type 来限制请求的映射 produces 指定请求头的 Accept 来限制请求的映射 params 指定请求的参数 headers 指定请求的请求头 @RestController @RequestMapping("/persons") class PersonController { @GetMapping("/{id}") public Person getPerson(@PathVariable Long id) { // ... } @GetMapping("/{name:[a-z-]+}-{version:\\d\\.\\d\\.\\d}{ext:\\.[a-z]+}") public void handle(@PathVariable String version, @PathVariable String ext) { // ... } @PostMapping(path = "/pets", consumes = "application/json") public void addPet(@RequestBody Pet pet) { // ... } @GetMapping(path = "/pets/{petId}", produces = "application/json;charset=UTF-8") @ResponseBody public Pet getPet(@PathVariable String petId) { // ... } @GetMapping(path = "/pets/{petId}", params = "myParam=myValue") public void findPet(@PathVariable String petId) { // ... } @GetMapping(path = "/pets", headers = "myHeader=myValue") public void findPet(@PathVariable String petId) { // ... } @PostMapping @ResponseStatus(HttpStatus.CREATED) public void add(@RequestBody Person person) { // ... } } 异常处理 @Controller public class SimpleController { // ... @ExceptionHandler public ResponseEntity<String> handle(IOException ex) { // ... } } ControllerAdvice —— 全局异常处理、全局数据预处理、全局数据绑定 @ControllerAdvice(basePackages = "com.cc.controller") public class SpringControllerAdvice { @ExceptionHandler(RuntimeException.class) public ModelAndView runtimeException(RuntimeException e) { return new ModelAndView("error"); } } @ControllerAdvice(basePackages = "com.cc.controller") public class SpringControllerAdvice { @InitBinder public void globalInitBinder(WebDataBinder binder) { binder.addCustomFormatter(new DateFormatter("yyyy-MM-dd")); } } @ControllerAdvice(basePackages = "com.cc.controller") public class SpringControllerAdvice { @ModelAttribute(value = "message") public String globalModelAttribute() { return "this is from model attribute"; } } MVC 配置 @EnableWebMvc 激活 实现 WebMvcConfigurer 添加功能 重写 addFormatters 进行类型转换 重写 getValidator 自定义全局 Validator 实例,也可以通过 @InitBinder 添加 @Controller public class MyController { @InitBinder protected void initBinder(WebDataBinder binder) { binder.addValidators(new FooValidator()); } } 重写 addInterceptors 添加拦截器 重写 configureContentNegotiation 配置请求的媒体类型 重写 configureMessageConverters 配置消息转换器 重写 addViewControllers 添加视图控制器 重写 configureViewResolvers 配置视图解析器 重写 addResourceHandlers 添加静态资源处理器 重写 configureDefaultServletHandling 配置默认 Servlet 处理器 重写 configurePathMatch 配置路径匹配 @Configuration @EnableWebMvc public class WebConfig implements WebMvcConfigurer { @Override public void addFormatters(FormatterRegistry registry) { // ... } @Override public Validator getValidator(); { // ... } @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new LocaleChangeInterceptor()); registry.addInterceptor(new ThemeChangeInterceptor()).addPathPatterns("/**").excludePathPatterns("/admin/**"); registry.addInterceptor(new SecurityInterceptor()).addPathPatterns("/secure/*"); } @Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer.mediaType("json", MediaType.APPLICATION_JSON); configurer.mediaType("xml", MediaType.APPLICATION_XML); } @Override public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder() .indentOutput(true) .dateFormat(new SimpleDateFormat("yyyy-MM-dd")) .modulesToInstall(new ParameterNamesModule()); converters.add(new MappingJackson2HttpMessageConverter(builder.build())); converters.add(new MappingJackson2XmlHttpMessageConverter(builder.createXmlMapper(true).build())); } @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/").setViewName("home"); } @Override public void configureViewResolvers(ViewResolverRegistry registry) { registry.enableContentNegotiation(new MappingJackson2JsonView()); registry.jsp(); } @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/resources/**") .addResourceLocations("/public", "classpath:/static/") .setCachePeriod(31556926); } @Override public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { configurer.enable();//或者 configurer.enable("myCustomDefaultServlet"); } @Override public void configurePathMatch(PathMatchConfigurer configurer) { configurer .setUseSuffixPatternMatch(true) .setUseTrailingSlashMatch(false) .setUseRegisteredSuffixPatternMatch(true) .setPathMatcher(antPathMatcher()) .setUrlPathHelper(urlPathHelper()) .addPathPrefix("/api", HandlerTypePredicate.forAnnotation(RestController.class)); } @Bean public UrlPathHelper urlPathHelper() { //... } @Bean public PathMatcher antPathMatcher() { //... } } 视图技术 Thymeleaf —— 现代化服务器端 Java 模板引擎,支持原生 HTML,可在浏览器中双击预览 FreeMarker —— 用于生成从 HTML 到电子邮件等类型文本输出的模板引擎 @Configuration @EnableWebMvc public class WebConfig implements WebMvcConfigurer { @Override public void configureViewResolvers(ViewResolverRegistry registry) { registry.freemarker(); } // Configure FreeMarker... @Bean public FreeMarkerConfigurer freeMarkerConfigurer() { FreeMarkerConfigurer configurer = new FreeMarkerConfigurer(); configurer.setTemplateLoaderPath("/WEB-INF/freemarker"); return configurer; } } <#import "/spring.ftl" as spring/> <html> ... <form action="" method="POST"> Name: <@spring.bind "myModelObject.name"/> <input type="text" name="${spring.status.expression}" value="${spring.status.value?html}"/><br> <#list spring.status.errorMessages as error> <b>${error}</b> <br> </#list> <br> ... <input type="submit" value="submit"/> </form> ... </html> Groovy Markup —— 生成类似于 XML 的标记 @Configuration @EnableWebMvc public class WebConfig implements WebMvcConfigurer { @Override public void configureViewResolvers(ViewResolverRegistry registry) { registry.groovy(); } // Configure the Groovy Markup Template Engine... @Bean public GroovyMarkupConfigurer groovyMarkupConfigurer() { GroovyMarkupConfigurer configurer = new GroovyMarkupConfigurer(); configurer.setResourceLoaderPath("/WEB-INF/"); return configurer; } } yieldUnescaped '<!DOCTYPE html>' html(lang:'en') { head { meta('http-equiv':'"Content-Type" content="text/html; charset=utf-8"') title('My page') } body { p('This is an example of HTML contents') } } 脚本视图 @Configuration @EnableWebMvc public class WebConfig implements WebMvcConfigurer { @Override public void configureViewResolvers(ViewResolverRegistry registry) { registry.scriptTemplate(); } @Bean public ScriptTemplateConfigurer configurer() { ScriptTemplateConfigurer configurer = new ScriptTemplateConfigurer(); configurer.setEngineName("nashorn"); configurer.setScripts("mustache.js"); configurer.setRenderObject("Mustache"); configurer.setRenderFunction("render"); return configurer; } } <html> <head> <title>{{title}}</title> </head> <body> <p>{{body}}</p> </body> </html> JSP <form:form> <table> <tr> <td>First Name:</td> <td><form:input path="firstName"/></td> </tr> <tr> <td>Last Name:</td> <td><form:input path="lastName"/></td> </tr> <tr> <td colspan="2"> <input type="submit" value="Save Changes"/> </td> </tr> </table> </form:form> RSS and Atom public class SampleContentAtomView extends AbstractAtomFeedView { @Override protected void buildFeedMetadata(Map<String, Object> model, Feed feed, HttpServletRequest request) { // implementation omitted } @Override protected List<Entry> buildFeedEntries(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { // implementation omitted } } public class SampleContentRssView extends AbstractRssFeedView { @Override protected void buildFeedMetadata(Map<String, Object> model, Channel feed, HttpServletRequest request) { // implementation omitted } @Override protected List<Item> buildFeedItems(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception { // implementation omitted } } PDF and Excel public class PdfWordList extends AbstractPdfView { protected void buildPdfDocument(Map<String, Object> model, Document doc, PdfWriter writer, HttpServletRequest request, HttpServletResponse response) throws Exception { List<String> words = (List<String>) model.get("wordList"); for (String word : words) { doc.add(new Paragraph(word)); } } } public class ExcelViewBuilder extends AbstractExcelView { protected void buildExcelDocument(Map<String,Object> model,HSSFWorkbook wb,HttpServletRequest req, HttpServletResponse resp) { // ... } } XSLT @EnableWebMvc @ComponentScan @Configuration public class WebConfig implements WebMvcConfigurer { @Bean public XsltViewResolver xsltViewResolver() { XsltViewResolver viewResolver = new XsltViewResolver(); viewResolver.setPrefix("/WEB-INF/xsl/"); viewResolver.setSuffix(".xslt"); return viewResolver; } } @Controller public class XsltController { @RequestMapping("/") public String home(Model model) throws Exception { Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); Element root = document.createElement("wordList"); List<String> words = Arrays.asList("Hello", "Spring", "Framework"); for (String word : words) { Element wordNode = document.createElement("word"); Text textNode = document.createTextNode(word); wordNode.appendChild(textNode); root.appendChild(wordNode); } model.addAttribute("wordList", root); return "home"; } } <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" omit-xml-declaration="yes"/> <xsl:template match="/"> <html> <head><title>Hello!</title></head> <body> <h1>My First Words</h1> <ul> <xsl:apply-templates/> </ul> </body> </html> </xsl:template> <xsl:template match="word"> <li><xsl:value-of select="."/></li> </xsl:template> </xsl:stylesheet>

优秀的个人博客,低调大师

scrapy官方文档提供的常见使用问题

Scrapy与BeautifulSoup或lxml相比如何? BeautifulSoup和lxml是用于解析HTML和XML的库。Scrapy是一个用于编写Web爬虫的应用程序框架,可以抓取网站并从中提取数据。 Scrapy提供了一种用于提取数据的内置机制(称为选择器),但如果您觉得使用它们感觉更舒服,则可以轻松使用BeautifulSoup(或lxml)。毕竟,他们只是解析可以从任何Python代码导入和使用的库。 换句话说,将BeautifulSoup(或lxml)与Scrapy进行比较就像将jinja2与Django进行比较一样。 我可以和BeautifulSoup一起使用Scrapy吗? 是的你可以。如所提到的上面,BeautifulSoup可用于在Scrapy回调解析HTML响应。您只需将响应的主体提供给BeautifulSo

优秀的个人博客,低调大师

Redisson官方文档 - 10. 额外功能

10.1. 对Redis节点的操作 Redisson的NodesGroup对象提供了许些对Redis节点的操作。 NodesGroup nodesGroup = redisson.getNodesGroup(); nodesGroup.addConnectionListener(new ConnectionListener() { public void onConnect(InetSocketAddress addr) { // Redis节点连接成功 } public void onDisconnect(InetSocketAddress addr) { // Redis节点连接断开 } }); 也可以用来PING单个Redis节点或全部节点。 NodesGroup nodesGroup = redisson.getNodesGroup(); Collection<Node> allNodes = nodesGroup.getNodes(); for (Node n : allNodes) { n.ping(); } // 或者 nodesGroup.pingAll(); 10.2. 复杂多维对象结构和对象引用的支持 Redisson突破了Redis数据结构维度的限制,通过一个特殊引用对象的帮助,Redisson允许以任意的组合方式构建多维度的复杂对象结构,实现了对象之间的类似传统数据库里的关联关系。使用范例如下: RMap<RSet<RList>, RList<RMap>> map = redisson.getMap("myMap"); RSet<RList> set = redisson.getSet("mySet"); RList<RMap> list = redisson.getList("myList"); map.put(set, list); // 在特殊引用对象的帮助下,我们甚至可以构建一个循环引用,这是通过普通序列化方式实现不了的。 set.add(list); list.add(map); 可能您已经注意到了,在map包含的元素发生改变以后,我们无需再次“保存/持久”这些对象。因为map对象所记录的并不是序列化以后的值,而是元素对象的引用。这让Redisson提供的对象在使用方法上,与普通Java对象的使用方法一致。从而让Redis成为内存的一部分,而不仅仅是一个储存空间。 以上范例中,一共创建了三个Redis数据结构:一个Redis HASH,一个Redis SET和一个Redis LIST。 10.3. 命令的批量执行 多个连续命令可以通过RBatch对象在一次网络会话请求里合并发送,这样省去了产生多个请求消耗的时间和资源。这在Redis中叫做管道。 RBatch batch = redisson.createBatch(); batch.getMap("test").fastPutAsync("1", "2"); batch.getMap("test").fastPutAsync("2", "3"); batch.getMap("test").putAsync("2", "5"); batch.getAtomicLongAsync("counter").incrementAndGetAsync(); batch.getAtomicLongAsync("counter").incrementAndGetAsync(); // 原子化(事务)批量执行所有的命令 batch.atomic(); // 告知Redis不用返回结果(可以减少网络用量) batch.skipResult(); // 将写入操作同步到从节点 // 同步到2个从节点,等待时间为1秒钟 batch.syncSlaves(2, 1, TimeUnit.SECONDS) // 处理结果超时为2秒钟 batch.timeout(2, TimeUnit.SECONDS); // 命令重试等待间隔时间为2秒钟 batch.retryInterval(2, TimeUnit.SECONDS); // 命令重试次数,仅适用于未发送成功的命令 batch.retryAttempts(4); BatchResult res = batch.execute(); // 或者 Future<BatchResult> asyncRes = batch.executeAsync(); 在集群模式下,所有的命令会按各个槽所在的节点,筛选分配到各个节点并同时发送。每个节点返回的结果将会汇总到最终的结果列表里。 10.4. 脚本执行 redisson.getBucket("foo").set("bar"); String r = redisson.getScript().eval(Mode.READ_ONLY, "return redis.call('get', 'foo')", RScript.ReturnType.VALUE); // 通过预存的脚本进行同样的操作 RScript s = redisson.getScript(); // 首先将脚本保存到所有的Redis主节点 String res = s.scriptLoad("return redis.call('get', 'foo')"); // 返回值 res == 282297a0228f48cd3fc6a55de6316f31422f5d17 // 再通过SHA值调用脚本 Future<Object> r1 = redisson.getScript().evalShaAsync(Mode.READ_ONLY, "282297a0228f48cd3fc6a55de6316f31422f5d17", RScript.ReturnType.VALUE, Collections.emptyList()); 10.5. 底层Redis客户端 Redisson在底层采用了高性能异步非阻塞式Java客户端,它同时支持异步和同步两种通信模式。如果有哪些命令Redisson还没提供支持,也可以直接通过调用底层Redis客户端来实现。Redisson支持的命令在Redis命令和Redisson对象匹配列表里做了详细对比参照。 // 在使用多个客户端的情况下可以共享同一个EventLoopGroup EventLoopGroup group = new NioEventLoopGroup(); RedisClientConfig config = new RedisClientConfig(); config.setAddress("redis://localhost:6379") // 或者用rediss://使用加密连接 .setPassword("myPassword") .setDatabase(0) .setClientName("myClient") .setGroup(group); RedisClient client = RedisClient.create(config); RedisConnection conn = client.connect(); // 或 RFuture<RedisConnection> connFuture = client.connectAsync(); conn.sync(StringCodec.INSTANCE, RedisCommands.SET, "test", 0); // 或 conn.async(StringCodec.INSTANCE, RedisCommands.GET, "test"); conn.close() // 或 conn.closeAsync() client.shutdown(); // 或 client.shutdownAsync();

优秀的个人博客,低调大师

Ubuntu 14.04+Apache+PHP+MySQL+EduSoho[文档]

版权声明:转载请注明出处:http://blog.csdn.net/dajitui2024 https://blog.csdn.net/dajitui2024/article/details/79396611 参考原文:http://www.qiqiuyu.com/course/20/task/793/show注意: 本教程基于Ubuntu系统 14.04版本并且需要以root用户操作机器,请在确保您的环境是否符合以上两个条件之后,再进行后续的操作。切记:我们的edusoho访问目录是edusoho/web,只有在nginx或者Apache配置里面把根目录定位到web目录下,才不会出现奇怪的问题,否则就会出现图片不能显示或者文件无法上传的问题。 1、更新和升级系统 sudo apt-get update sudo apt-get upgrade 2、安装和配置apache 2.1、安装apache sudo apt-get install apache2 sudo apt-get install libapache2-mod-xsendfile 2.2、配置apache虚拟主机 apache说2.2的版本: 打开apache的配置文件httpd.conf 找到 #LoadModule rewrite_module modules/mod_rewrite.so 把前面#去掉。没有则添加,但必选独占一行,使apache支持 mod_rewrite 模块 apache说2.4的版本: 默认开启,在/etc/apache2/mods-available下存在rewrite.load 这个配置说明已启用 sudo a2enmod rewrite #启用rewrite模块 sudo a2enmod xsendfile #启用xsendfile模块 vi /etc/apache2/sites-enabled/edusoho.conf 将以下代码添加到虚拟主机配置中 <VirtualHost *:80> ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/project/web <Directory /var/www/project/web> # enable the .htaccess rewrites AllowOverride All Require all granted </Directory> ErrorLog /var/log/apache2/project_error.log CustomLog /var/log/apache2/project_access.log combined </VirtualHost> 注意:apache2.2和2.4稍有不同,如果您是2.2,将<Directory>节点修改为: <Directory /var/www/project/web> # enable the .htaccess rewrites AllowOverride All Order allow,deny Allow from All </Directory> 注意: 1、将DocumentRoot、ServerName、伪静态路径修改为您安装系统的目录,保存修改。 2、rm /etc/apache2/sites-enabled/000-default -Rf 3、安装和配置PHP 3.1、安装PHP以及相关的插件 sudo apt-get install php5 php5-cli php5-curl php5-fpm php5-intl php5-mcrypt php5-mysqlnd php5-gd libapache2-mod-php5 3.2、修改PHP配置 #编辑php.ini , 将以下配置的值修改为1024M vi /etc/php5/apache2/php.ini memory_limit = 1024M post_max_size = 1024M upload_max_filesize = 1024M 重启Apache service apache2 restart 4、安装MySql和创建EduSoho数据库 apt-get install mysql-server 备注:安装过程中注意设定MySql的root密码,不设置默认为空,通常密码设置为root。 mysql -uroot -p 然后你需要输入MySQL数据库的root密码。 进入数据库命令行模式后,创建edusoho数据库,执行: CREATE DATABASE `edusoho` DEFAULT CHARACTER SET utf8 ; GRANT ALL PRIVILEGES ON `edusoho`.* TO 'esuser'@'localhost' IDENTIFIED BY 'edusoho'; quit; 注意:这里为edusoho数据库创建了一个用户名,用户名为:esuser,密码为edusoho,在后面安装的第三步需要用到,不建议直接填写root账户。 5、下载和解压EduSoho程序 mkdir /var/www cd /var/www wget http://download.edusoho.com/edusoho-VERSION.tar.gz (注:将VERSION替换为当前EduSoho最新版本号,可从官网www.edusoho.com查询获取) tar -zxvf edusoho-VERSION.tar.gz chown www-data:www-data edusoho/ -Rf 注:这里的下载地址可以在http://download.edusoho.com/中可以获取到,VERSION为下载来之后压缩包后面的版本号。 最后一步: 浏览器中打开:http://YOU_DOMAIN 安装,当然这里的YOU_DOMAIN是您的域名。

优秀的个人博客,低调大师

Android 中文 API 文档 (45) —— AbsoluteLayout.LayoutParams

正文 一、结构 public static classAbsoluteLayout.LayoutParamsextendsViewGroup.LayoutParams java.lang.Object android.view.ViewGroup.LayoutParams android.widget.AbsoluteLayout.LayoutParams 二、概述 每个子元素布局信息与绝对布局相关联。参见绝对布局属性中该类所支持的子视图属性列表。(译者注: AbsoluteLayout的这种“绝对”定位的布局方式和我们非常熟悉的Windows编程中的Left和Top设置UI元素的位置是基本一致的。) 三、字段 public int x 在View Group内部子元素中的X水平位置。 public int y 在View Group内部子元素中的Y垂直位置。 四、构造函数 public AbsoluteLayout.LayoutParams(int width, int height, int x, int y) 创建一个新的具有指定宽度、高度和位置的布局参数。 参数: widthMATCH_PARENT,WRAP_CONTENT或者固定大小的像素 heightMATCH_PARENT,WRAP_CONTENT或者固定大小的像素 x子元素的X位置 y子元素的Y位置 public AbsoluteLayout.LayoutParams(Context c, AttributeSet attrs) 创建一组新的布局参数,通过上下文提取的相关属性值设置。XML属性映射到这个布局参数设置如下: ·layout_x:子元素的X位置 ·layout_y:子元素的Y位置 ·所有来自ViewGroup.LayoutParams的XML属性 参数: c上下文环境. attrs从属性设置中提取布局参数值。 public AbsoluteLayout.LayoutParams(ViewGroup.LayoutParams source) (译者注:根据ViewGroup.LayoutParams实例化布局参数,从源码可以看出: 五、公共方法 public String debug (String output) 返回设置的布局参数的字符串表示形式。 参数 output用于内部表示的预置字符串 返回值 返回如下格式字符串:输出+ "ViewGroup.LayoutParams={ width=WIDTH, height=HEIGHT }" 本文转自over140 51CTO博客,原文链接:http://blog.51cto.com/over140/582598,如需转载请自行联系原作者

优秀的个人博客,低调大师

Android 中文 API 文档 (44) —— Chronometer.OnChronometerTickListener

正文 一、结构 public static interfaceChronometer.OnChronometerTickListener 二、概述 计时器递增的时候通知这个回调。 三、公共方法 public abstract voidonChronometerTick(Chronometer chronometer) 在计时器变化时通知。 参数 chronometer计时器对象。 本文转自over140 51CTO博客,原文链接:http://blog.51cto.com/over140/582600,如需转载请自行联系原作者

资源下载

更多资源
Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册