精华内容
下载资源
问答
  • 然后计算分支的上下文无关或上下文相关替换替换长度以及分支之间替换长度的方差-协方差矩阵。 它以 Multidivtime 的输入格式生成输出,以便在 Multidivtime 中可以将每个替换类型视为单个基因(位点)。 入门 ...
  • different. For example: id = "insertUser" parameterType = "User" > insert into users (id, username, password) values (#{id}, #{username}, #{password}) If a parameter object of type ...

    中文翻译

    Parameters部分:

    Parameters参数是MyBatis中非常强大的元素,正常来说90%以上的情况你要用的,都应该是#{}

    1.parameter mapping,命名参数映射。如果你传入的参数是一个对象(指复杂对象,非Integer或者String这些简单的),用paramterType="object"的情况,可以直接用#{attribute}取值。

    <!--by zhengkai.blog.csdn.net--> 
    <insert id="insertUser" parameterType="User">
      insert into users (id, username, password)
      values (#{id}, #{username}, #{password})
    </insert>
    

    2.对于需要特殊指定javaType或者jdbcType的,可以在#{param}中进行指定,你还可以在这里指定numericScale小数位。

    #{height,javaType=double,jdbcType=NUMERIC,numericScale=2}
    

    3.甚至你还可以自定义typeHandler来处理一些特殊的情况和特殊的类型,通常有两种方式,一种是实现TypeHandler接口,还有一种就是继承自BaseTypeHandler类(这种应该比较少,用了这么久我还没处理过)。

    #{age,javaType=int,jdbcType=NUMERIC,typeHandler=MyTypeHandler}
    

    4.另外,mode属性允许您指定IN,OUT或INOUT参数。 如果参数为OUT或INOUT,则参数对象属性的实际值将会更改,就像调用输出参数时那样。 如果mode = OUT/INOUT且jdbcType = CURSOR(即Oracle REFCURSOR),则必须指定resultMap以将ResultSet映射到参数的类型。 请注意,javaType属性在这里是可选的,如果留空并使用CURSOR作为jdbcType,它将自动设置为ResultSet。

    #{department, mode=OUT, jdbcType=CURSOR, javaType=ResultSet, resultMap=departmentResultMap}
    

    *。默认情况下,使用#{}语法将导致MyBatis生成PreparedStatement属性并根据PreparedStatement参数安全地设置值(例如?)。

    String Substitution部分:

    1.虽然#{}更安全,更快速且几乎总是首选,但有时您只想将未修改的字符串直接注入SQL语句。 例如,对于ORDER BY,就要用String Substitution,字符串替换了。

    ORDER BY ${columnName}
    

    2.另外一种高端自由查询的用法, 你可以用${column}指定查询字段,用#{value}指定查询的,是不是很6的用法。

    @Select("select * from user where ${column} = #{value}")
    User findByColumn(@Param("column") String column, @Param("value") String value);
    

    3.字符串替换是很弱的安全性能,容易被SQL注入,所以用的时候请保持小心。原则是:能用参数替换就用参数,不能用或者动态字段查询才用字符串替换

    英文原文

    http://www.mybatis.org/mybatis-3/sqlmap-xml.html

    Parameters

    In all of the past statements, you've seen examples of simple parameters. Parameters are very powerful elements in MyBatis. For simple situations, probably 90% of the cases, there's not much to them, for example:

    <select id="selectUsers" resultType="User">
      select id, username, password
      from users
      where id = #{id}
    </select>

    The example above demonstrates a very simple named parameter mapping. The parameterType is set to int, so therefore the parameter could be named anything. Primitive or simple data types such as Integer and String have no relevant properties, and thus will replace the full value of the parameter entirely. However, if you pass in a complex object, then the behavior is a little different. For example:

    <insert id="insertUser" parameterType="User">
      insert into users (id, username, password)
      values (#{id}, #{username}, #{password})
    </insert>

    If a parameter object of type User was passed into that statement, the id, username and password property would be looked up and their values passed to a PreparedStatement parameter.

    That's nice and simple for passing parameters into statements. But there are a lot of other features of parameter maps.

    First, like other parts of MyBatis, parameters can specify a more specific data type.

    #{property,javaType=int,jdbcType=NUMERIC}

    Like the rest of MyBatis, the javaType can almost always be determined from the parameter object, unless that object is a HashMap. Then the javaType should be specified to ensure the correct TypeHandler is used.

    NOTE The JDBC Type is required by JDBC for all nullable columns, if null is passed as a value. You can investigate this yourself by reading the JavaDocs for the PreparedStatement.setNull() method.

    To further customize type handling, you can also specify a specific TypeHandler class (or alias), for example:

    #{age,javaType=int,jdbcType=NUMERIC,typeHandler=MyTypeHandler}

    So already it seems to be getting verbose, but the truth is that you'll rarely set any of these.

    For numeric types there's also a numericScale for determining how many decimal places are relevant.

    #{height,javaType=double,jdbcType=NUMERIC,numericScale=2}

    Finally, the mode attribute allows you to specify IN, OUT or INOUT parameters. If a parameter is OUT or INOUT, the actual value of the parameter object property will be changed, just as you would expect if you were calling for an output parameter. If the mode=OUT (or INOUT) and the jdbcType=CURSOR (i.e. Oracle REFCURSOR), you must specify a resultMap to map the ResultSet to the type of the parameter. Note that the javaType attribute is optional here, it will be automatically set to ResultSet if left blank with a CURSOR as the jdbcType.

    #{department, mode=OUT, jdbcType=CURSOR, javaType=ResultSet, resultMap=departmentResultMap}

    MyBatis also supports more advanced data types such as structs, but you must tell the statement the type name when registering the out parameter. For example (again, don't break lines like this in practice):

    #{middleInitial, mode=OUT, jdbcType=STRUCT, jdbcTypeName=MY_TYPE, resultMap=departmentResultMap}

    Despite all of these powerful options, most of the time you'll simply specify the property name, and MyBatis will figure out the rest. At most, you'll specify the jdbcType for nullable columns.

    #{firstName}
    #{middleInitial,jdbcType=VARCHAR}
    #{lastName}

    String Substitution

    By default, using the #{} syntax will cause MyBatis to generate PreparedStatement properties and set the values safely against the PreparedStatement parameters (e.g. ?). While this is safer, faster and almost always preferred, sometimes you just want to directly inject an unmodified string into the SQL Statement. For example, for ORDER BY, you might use something like this:

    ORDER BY ${columnName}

    Here MyBatis won't modify or escape the string.

    String Substitution can be very useful when the metadata(i.e. table name or column name) in the sql statement is dynamic, for example, if you want to select from a table by any one of its columns, instead of writing code like:

    @Select("select * from user where id = #{id}")
    User findById(@Param("id") long id);
    

    @Select(“select * from user where name = #{name}”)
    User findByName(@Param(“name”) String name);

    @Select(“select * from user where email = #{email}”)
    User findByEmail(@Param(“email”) String email);

    // and more “findByXxx” method
    you can just write:

    @Select("select * from user where ${column} = #{value}")
    User findByColumn(@Param("column") String column, @Param("value") String value);
    in which the ${column} will be substituted directly and the #{value} will be "prepared". Thus you can just do the same work by:
    User userOfId1 = userMapper.findByColumn("id", 1L);
    User userOfNameKid = userMapper.findByColumn("name", "kid");
    User userOfEmail = userMapper.findByColumn("email", "noone@nowhere.com");

    This idea can be applied to substitute the table name as well.

    NOTE It's not safe to accept input from a user and supply it to a statement unmodified in this way. This leads to potential SQL Injection attacks and therefore you should either disallow user input in these fields, or always perform your own escapes and checks.

    展开全文
  • springboot替换tomcat

    2020-10-05 20:32:06
    switching to a different HTTP server, you need to exclude the default dependencies in addition to including the one you need. To help with this process, Spring Boot provides a separate starter for ...

    switching to a different HTTP server, you need to exclude the default dependencies in
    addition to including the one you need. To help with this process, Spring Boot provides a separate
    starter for each of the supported HTTP servers.

    <properties>
      <servlet-api.version>3.1.0</servlet-api.version>
    </properties>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      <exclusions>
      <!-- Exclude the Tomcat dependency -->
      <exclusion>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
      </exclusion>
      </exclusions>
    </dependency>
    <!-- Use Jetty instead -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-jetty</artifactId>
    </dependency>
    
    ... 
    The version of the Servlet API has been overridden as, unlike Tomcat 9 and
    Undertow 2.0, Jetty 9.4 does not support Servlet 4.0.
    
    To scan for a free port (using OS natives to prevent clashes) use server.port=0
    
    展开全文
  • 语言:English 调整Gmail Web interface的删除按钮。 此扩展名替换Gmail的删除按钮的图标,具有较少的微妙版本。 (如果您在Gmail设置的“按钮标签”部分中选择了“文本”,则它将没有效果。)
  • ruby字符串替换 Splitting a string is only one way to manipulate string data. You can also make substitutions to replace one part of a string with another string. For instance, in an example string ...

    ruby字符串替换

    Splitting a string is only one way to manipulate string data. You can also make substitutions to replace one part of a string with another string. For instance, in an example string (foo,bar,baz) replacing "foo" with "boo" in would yield "boo,bar,baz." You can do this and many more things using the sub and gsub method in the string class.

    拆分字符串只是操作字符串数据的一种方法。 您还可以进行替换,以将字符串的一部分替换为另一字符串。 例如,在示例字符串(foo,bar,baz)中将“ foo”替换为“ boo”将产生“ boo,bar,baz”。 您可以使用字符串类中的subgsub方法执行此操作以及执行更多操作。

    Ruby替代的许多选择 ( Many Options for Ruby Substitution )

    The substitution methods come in two varieties. The sub method is the most basic of the two and comes with the least number of surprises. It simply replaces the first instance of the designated pattern with the replacement.

    替代方法有两种。 方法是这两种方法中最基本的方法,并且惊喜最少。 它只是用替换替换了指定模式的第一个实例。

    Whereas sub only replaces the first instance, the gsub method replaces every instance of the pattern with the replacement. In addition, both sub and gsub have sub! and gsub! counterparts. Remember, methods in Ruby that end in an exclamation point alter the variable in place instead of returning a modified copy.

    sub仅替换第一个实例,而gsub方法用替换替换模式的每个实例。 另外, subgsub都有sub!gsub! 同行。 请记住, Ruby中以感叹号结尾的方法会在适当位置更改变量,而不是返回修改后的副本。

    搜索和替换 ( Search and Replace )

    The most basic usage of the substitution methods is to replace one static search string with one static replacement string. In the above example, "foo" was replaced with "boo." This can be done for the first occurrence of "foo" in the string using the sub method or with all occurrences of "foo" using the gsub method.

    替换方法的最基本用法是用一个静态替换字符串替换一个静态搜索字符串。 在上面的示例中,“ foo”被替换为“ boo”。 可以使用sub方法在字符串中首次出现“ foo”的情况下进行此操作,或者使用gsub方法使用“ foo”的所有出现的情况进行此操作。


    a = "foo,bar,baz"
    a =“ foo,bar,baz”
    b = a.sub( "foo", "boo" )
    b = a.sub(“ foo”,“ boo”)
    puts b
    把b

    foo,bar,baz
    foo,bar,baz
    gsub$ ./1.rb
    gsub $ ./1.rb
    boo,bar,baz
    嘘,吧,巴兹

    灵活的搜索 ( Flexible Searching )

    Searching for static strings can only go so far. Eventually, you'll run into cases where a subset of strings or strings with optional components will need to be matched. The substitution methods can, of course, match regular expressions instead of static strings. This allows them to be much more flexible and match virtually any text you can dream up.

    搜索静态字符串只能走这么远。 最终,您将遇到需要匹配字符串子集或带有可选组件的字符串的情况。 当然,替换方法可以匹配正则表达式而不是静态字符串。 这使它们更加灵活,并且可以匹配您可以梦想的任何文本。

    This example is a little more real world. Imagine a set of comma-separated values. These values are fed into a tabulation program over which you have no control (closed source). The program that generates these values is closed source as well, but it's outputting some badly-formatted data. Some fields have spaces after the comma and this is causing the tabulator program to break.

    这个例子更真实一些。 想象一组用逗号分隔的值。 这些值将输入到您无法控制的制表程序中(封闭 )。 生成这些值的程序也是封闭源,但它输出的是格式错误的数据。 某些字段在逗号后有空格,这导致制表程序中断。

    One possible solution is to write a Ruby program to act as "glue," or a filter, between the two programs. This Ruby program will fix any problems in the data formatting so the tabulator can do its job. To do this, it's quite simple: replace a comma followed by a number of spaces with just a comma.

    一种可能的解决方案是编写一个Ruby程序,在两个程序之间充当“胶水”或过滤器。 这个Ruby程序将解决数据格式中的所有问题,以便制表器可以完成其工作。 为此,这非常简单:用逗号替换逗号,然后将多个空格替换为逗号。


    STDIN.each do|l|
    STDIN.each do | l |
    l.gsub!( /, +/, "," )
    l.gsub!(/,+ /,“,”)
    puts l
    放l
    end
    结束

    10, 20, 30
    10、20、30
    12.8, 10.4,11
    12.8、10.4、11
    gsub$ cat data.txt | ./2.rb
    gsub $ cat data.txt | ./2.rb
    10,20,30
    10,20,30
    12.8,10.4,11
    12.8,10.4,11

    灵活的替换 ( Flexible Replacements )

    Now imagine this situation. In addition to the minor formatting errors, the program that produces the data produces number data in scientific notation. The tabulator program doesn't understand this, so you're going to have to replace it. Obviously, a simple gsub won't do here because the replacement will be different every time the replacement is done.

    现在想象一下这种情况。 除了较小的格式错误外 ,生成数据的程序还会以科学计数法生成数字数据。 制表器程序不理解这一点,因此您将不得不替换它。 显然,这里不会做一个简单的gsub,因为每次替换完成后替换都会不同。

    Luckily, the substitution methods can take a block for the substitution arguments. For each time the search string is found, the text that matched the search string (or regex) is passed to this block. The value yielded by the block is used as the substitution string. In this example, a floating point number in scientific notation form (such as 1.232e4) is converted to a normal number with a decimal point. The string is converted to a number with to_f, then the number is formatted using a format string.

    幸运的是,替换方法可以为替换参数取一个块。 每次找到搜索字符串时,与搜索字符串(或正则表达式)匹配的文本都会传递到此块。 该块产生的值用作替换字符串。 在此示例中,科学计数形式的浮点数(例如1.232e4 )被转换为带小数点的普通数。 使用to_f将字符串转换为数字,然后使用格式字符串对数字进行格式化。


    STDIN.each do|l|
    STDIN.each do | l |
    l.gsub!( /-?\d+\.\d+e-?\d+/) do|n|
    l.gsub!(/-?\d+\.\d+e-?\d+/)do | n |
    "%.3f" % n.to_f
    “%.3f”%n.to_f
    end
    结束
    l.gsub!( /, +/, "," )
    l.gsub!(/,+ /,“,”)
    puts l
    放l
    end
    结束

    2.215e-1, 54, 11
    2.215e-1、54、11
    3.15668e6, 21, 7
    3.15668e6,21,7
    gsub$ cat floatdata.txt | ./3.rb
    gsub $ cat floatdata.txt | ./3.rb
    0.222,54,11
    0.222,54,11
    3156680.000,21,7
    3156680.000,21,7

    不熟悉正则表达式? ( Not Familiar With Regular Expressions? )

    Let's take a step back and look at that regular expression. It looks cryptic and complicated, but it's very simple. If you're not familiar with regular expressions, they can be quite cryptic. However, once you are familiar with them, they're straightforward and natural methods of describing text. There are a number of elements, and several of the elements have quantifiers.

    让我们退后一步,看看该正则表达式 。 它看起来神秘而复杂,但是非常简单。 如果您不熟悉正则表达式,那么它们可能会很神秘。 但是,一旦您熟悉它们,它们就是描述文本的直接而自然的方法。 有许多元素,并且其中一些元素带有量词。

    The primary element here is the \d character class. This will match any digit, the characters 0 through 9. The quantifier + is used with the digit character class to signify that one or more of these digits should be matched in a row. You have three groups of digits, two separated by a "." and the other separated by the letter "e" (for exponent).

    这里的主要元素是\ d字符类。 这将匹配任何数字(字符0到9)。数字字符类与量词+一起使用,表示应连续匹配其中一个或多个数字。 您有三组数字,两组数字之间用“ ”分隔,另一组数字由字母“ e ”分隔(用于指数)。

    The second element floating around is the minus character, which uses the "?" quantifier. This means "zero or one" of these elements. So, in short, there may or may not be negative signs at the beginning of the number or exponent.

    浮动的第二个元素是减号,它使用“ ”量词。 这意味着这些元素为“零或一”。 简而言之,在数字或指数的开头可能没有负号。

    The two other elements are the . (period) character and the e character. Combine all this, and you get a regular expression (or set of rules for matching text) that matches numbers in scientific form (such as 12.34e56).

    其他两个元素是 (句点)字符和e字符。 结合所有这些,您将获得一个与科学形式(例如12.34e56 )匹配的正则表达式(或匹配文本的规则集)。

    翻译自: https://www.thoughtco.com/string-substitution-in-ruby-2907752

    ruby字符串替换

    展开全文
  • java中替换字符以及回车换行

    千次阅读 2018-06-09 15:11:48
    //第一种方式 import java.util.regex.Pattern; import java.util.regex.Matcher; ... // 4 different com
    原文地址为:
    java中替换字符以及回车换行
    

    //第一种方式
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    
    ...
    // 4 different combinaisons
    Pattern CRLF = Pattern.compile("(\r\n|\r|\n|\n\r)");
    Matcher m = CRLF.matcher(myString);
     
    if (m.find()) {
      newString = m.replaceAll("<br>");
    }
    //第二种方式
    
    newString = myString.replaceAll("(\r\n|\r|\n|\n\r)", "<br>");
    

    测试

    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    
    public class StringTest {
    
    	public static String sss(String myString){
    		String newString=null;
    		Pattern CRLF = Pattern.compile("(\r\n|\r|\n|\n\r)");
    		Matcher m = CRLF.matcher(myString);
    		if (m.find()) {
    		  newString = m.replaceAll("<br>");
    		}
    		return newString;
    	}
    	/**
    	 * @param args
    	 */
    	public static void main(String[] args) {
    		String aaa="sdfsfdsfsdf\r\n,dsfsdfsdf\r\n";
    		//aaa.replace("s", "x");
    		String newStr=sss(aaa);
    		System.out.println(newStr);
    	}
    
    }



    转载请注明本文地址: java中替换字符以及回车换行
    展开全文
  • scala字符串替换 Scala | 替换字符串中的正则表达式模式 (Scala | Replacing a regular expression pattern in a string) Replacing a part of the string that matches our given regular expression can be done ...
  • 经典的SEND + MORE = ... 这里用Minizinc语言中的alldifferent全局变量,顾名思义,数组中的所有元素都不相同。  使用前需要提前引如alldifferent.mzn文件或者globals.mzn  代码如下:  % SEND + MORE = MONEY
  • Tex中的正则表达式替换

    千次阅读 2013-03-18 14:20:15
    本人在用Tex写论文时,碰到要将\textbf{NumEQ},\textbf{NumBC},\...因为文章中有大量地方需要修改,手动修改机耗时又可能漏掉,最终采用正则表达式替换修改。 对被替换的字符换描述为: \\textbf\{\(*\)\}
  • ARM公司关于嵌入式系统中不同Cache替换策略的研究论文
  • Mybatis参数变量替换流程

    千次阅读 2016-12-20 09:10:10
    记录mybatis参数变量替换流程
  • 最近在搞Windows项目往Linux移植,遇到个问题是windows 的WaitForSingleObject 如何使用Linux的方式替换,先贴一下代码:#ifndef _OSA_SEM_H_ #define _OSA_SEM_H_ #include "globalDefine.h" #include #include ...
  • 在写代码的时候出现以下错误:AssertionError: size of input tensor and input format are different. tensor shape: (64, 3, 32, 32), input_format: CHW 原因:tensor的维度是(64,3,32,32)而要求的输入格式是CHW...
  • 在redmine安装包路径下面执行bundle install命令,提示错误:[root@vps ...You cannot specify the same gem twice with different version requirements. You specified: i18n (~> 0.6.0) and i18n (= 0.4.2)遇到
  • 把每一个元素替换成上一次该元素出现的位置与现在的位置的距离 将新的序列做一遍最小表示法 将最小表示的序列加到set中 最后答案即为set的大小 代码: 12548936 2015-08-15 17:29:14 NKWBTB D - Different ...
  • CMake OpenCV时出现错误,提示:Re-run cmake with a different source directory. 看到别人的解决方法:删除执行cmake的文件夹中的CMakeCache.txt 尝试后发现仍然报一样的错,最终的解决方法是把生成目录更改一下...
  • 原串中需要替换的占位符为"%s",请按照参数列表的顺序一一替换占位符。若参数列表的字符数大于占位符个数。 则将剩下的参数字符添加到字符串的结尾。给定一个字符串A,同时给定它的长度n及参数字符数组arg和它的大小...
  • vim的查找与替换

    千次阅读 2014-11-17 22:07:33
    参考资料 [1]VIM中的搜索和替换 [2]
  • Java字符串替换

    2020-07-13 10:54:52
    Sometimes it’s not possible because the input string may be different because of case. In this scenario we can use replaceAll method and pass regular expression for case insensitive replacement. Let...
  • 调整Gmail网页界面的删除按钮。 此扩展程序以不太敏感的版本替换了Gmail的“删除”按钮的图标。 (如果您在Gmail设置的“按钮标签”部分中选择了“文本”,则该文本将无效。) 支持语言:English
  • 当一个cache想要load数据到寄存器时,检查cache中的line,如果hit了就get到数据,否则将整条line从主存中去出来,(通常通过LRU)替换cache中一条line。寄存器传数据到cache也一样的过程。 Importance of Locality ...
  • 基本上就这个三个步骤,就能替换原来的存储路径了。 本文出自  “orangleliu笔记本”  博客,转载请务必保留此出处 http://blog.csdn.net/orangleliu/article/details/40542099 作者: orangleliu ...
  • 使用 Undertow 替换掉 Tomcat

    万次阅读 2018-11-01 14:24:55
      When switching to a different HTTP server, you need to exclude the default dependencies in addition to including the one you need. Spring Boot provides separate starters for ...
  • 什么场景下将MySQL替换为HBase

    千次阅读 2016-07-31 12:17:30
    That's an entirely different discussion. 2. To achieve scalability, HBase makes trade offs on certain properties. For instance, HBase does not provide cross row transactions. 3. ...
  • 错误现象:libboost_system-mgw53-mt-d-x32-1_67.a(error_code.o): duplicate ...`.rdata$_ZTVN5boost6system14error_category12std_categoryE[__ZTVN5boost6system14error_category12std_categoryE]' has different...
  • svn is already a working copy for a different URL  2009-03-18 17:36:54| 分类: Flex开发 |举报 |字号 订阅 运行更新脚本的时候出现如题的错误,google了一把找到了解决办法。 ...
  • (译)Xposed-替换资源

    千次阅读 2017-02-06 11:57:46
    Xposed使得替换资源,比如:图像和字符串之类的事变得容易。下面是做法: 简单的资源 @Override public void initZygote(IXposedHookZygoteInit.StartupParam startupParam) throws Throwable { XResources.se
  • 我们需要将里面的包替换,可能由于版本原因,或者修改了包的位置,所以需要修改包的来源,replace的作用就是将当前代码中的包替换成当下的包。这样就可以继续使用了。 我们需要修改的是go.mod文件,然后再继续安装就...
  • MySQL数据迁移 data目录直接替换 InnoDB: Error: log file ./ib_logfile0 is of different size InnoDB: than specified in the .cnf file

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 33,128
精华内容 13,251
关键字:

different替换