'spring framework'에 해당되는 글 3건

  1. 2012/02/23 visualp mybatis , 멀티 파라메터 전달 ,anotation parameter injection
  2. 2012/02/23 visualp mybatis , select query , return arraylist
  3. 2012/02/17 visualp spring 3.0 utf-8 filter
[출처] :http://stackoverflow.com/questions/16712462/many-commandname-for-one-form-in-spring-mvc
public
classCombinedCommand(){Activity activity;Etabl etabl;//Getter and setter}

jsp:

<form:form
  action="${pageContext.request.contextPath}/ajouter_activite"
  method="post" commandName="combinedCommand"">...<form:input type="text"path="activity.x"/>...<form:input type="text"path="etabl.y"/>...</form:form>
2015/12/14 11:24 2015/12/14 11:24
받은 트랙백이 없고, 댓글이 없습니다.

댓글+트랙백 RSS :: http://blog.visualp.com/rss/response/703

댓글+트랙백 ATOM :: http://blog.visualp.com/atom/response/703

[원문]
http://viralpatel.net/blogs/spring-mvc-multi-row-submit-java-list/

[정리]

ArrayList 형태의 DTO 또는 VO 객체를 생성후

그 beens 객체를 jstl foreach로 반복 해주면 됨 .


2015/06/22 10:59 2015/06/22 10:59
받은 트랙백이 없고, 댓글이 없습니다.

댓글+트랙백 RSS :: http://blog.visualp.com/rss/response/690

댓글+트랙백 ATOM :: http://blog.visualp.com/atom/response/690

<원문>http://nimba.tistory.com/m/post/457

    @RequestMapping(value = "/servicelogo/{path1}/{file_name:.+}", method = RequestMethod.GET, produces = "application/octet-stream")
    @ResponseBody
    public FileSystemResource getPublicFile2(
            @PathVariable("file_name") String fileName,
            @PathVariable("path1") String path1,
            HttpServletResponse response) throws Exception {
        Map<String, Object> condition = new HashMap<String, Object>();
        if(path1.equals("front")) {
            condition.put("front_logo_img", fileName);
        } else if(path1.equals("print")) {
            condition.put("print_logo_img", fileName);   
        } else {
            condition.put("front_logo_img", fileName);
        }
       
        String serverFileName = Admin2Service.getServiceLogoFileName(condition);
        logger.debug("serverFileName= "+serverFileName);
       
        if(serverFileName == null || serverFileName.length()==0 || serverFileName.equals("")) serverFileName = "temp.jpg";
       
        String uploadDir = "/upload/serviceLogo";
        File f = new File(messageBundle.getMessage("file.uploadPath") + uploadDir + "/" + serverFileName);
       
        response.setContentType("application/octet-stream");
        return new FileSystemResource(f);
    }

2015/06/18 17:05 2015/06/18 17:05
받은 트랙백이 없고, 댓글이 없습니다.

댓글+트랙백 RSS :: http://blog.visualp.com/rss/response/689

댓글+트랙백 ATOM :: http://blog.visualp.com/atom/response/689

Currently multiple parameters must be declared in the mapper interface using @Param annotation:

public interface SomeMapper {
    public SomeClass getWith2Params(@Param("p1") int p1, @Param("p2") String p2);
}

And then in mapper file:

<select id="getWith2Params" resultType="SomeClass">
        SELECT *
        FROM SomeTable
        WHERE p1 = #{p1} AND p2= #{p2}
</select>

Unlike single parameter, multiple parameters are not declared in the same place where they are used and this makes the coding less productive,
maintainable and readable.

An alternative to annotation for having full declaration and usage in the mapper file would be something like:

<select id="getWith2Params" parameters="int p1; string p2" resultType="SomeClass">
        SELECT *
        FROM SomeTable
        WHERE p1 = #{p1} AND p2= #{p2}
</select>

or

<select id="getWith2Params" parameters="int; string" resultType="MyClass">
        SELECT *
        FROM SomeTable
        WHERE p1 = #{1} AND p2= #{2}
</select>

This way all information regarding the query is kept in one simple
place, the mapper file, and no annotation would be required.

------------

@Param usage may also be simplified overriding it with a no-argument version:

public interface SomeMapper {
    public SomeClass getWith2Params(@Param int p1, @Param String p2);
}

And using parameter position in the query:

<select id="getWith2Params" resultType="SomeClass">
        SELECT *
        FROM SomeTable
        WHERE p1 = #{1} AND p2= #{2}
</select>

Or even (if possible) extracting the name of the parameters from @Param annotation:

<select id="getWith2Params" resultType="SomeClass">
        SELECT *
        FROM SomeTable
        WHERE p1 = #{p1} AND p2= #{p2}
</select>

instead of repeat declaring the name of the parameter.




2012/02/23 17:23 2012/02/23 17:23
받은 트랙백이 없고, 댓글이 없습니다.

댓글+트랙백 RSS :: http://blog.visualp.com/rss/response/462

댓글+트랙백 ATOM :: http://blog.visualp.com/atom/response/462

In mybatis passing array list is as simple as passing a map into

please follow the below codes

Any Dao method like

   List<domain.blog.Post> selectPostIn ( List<String> params );

And the Dao.xml
<select id="selectPostIn" resultType="domain.blog.Post"  parameterType="java.util.List">
 SELECT * FROM POST P WHERE ID in
    <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
      #{item}
    </foreach>
</select>
Just make sure collection name should be "list" only
You can pass a List instance or an Array to MyBatis as a parameter object. When you do, MyBatis will automatically wrap it in a Map, and key it by name. List instances will be keyed to the name “list” and array instances will be keyed to the name “array”

I have tried with list its working
2012/02/23 16:33 2012/02/23 16:33
받은 트랙백이 없고, 댓글이 없습니다.

댓글+트랙백 RSS :: http://blog.visualp.com/rss/response/461

댓글+트랙백 ATOM :: http://blog.visualp.com/atom/response/461

spring 3.0 utf-8 filter

spring framework RSS Icon ATOM Icon 2012/02/17 10:48 visualp

web.xml에 추가해주세요

<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>

2012/02/17 10:48 2012/02/17 10:48
받은 트랙백이 없고, 댓글이 없습니다.

댓글+트랙백 RSS :: http://blog.visualp.com/rss/response/457

댓글+트랙백 ATOM :: http://blog.visualp.com/atom/response/457