Posted
Filed under spring framework
[출처] :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
Posted
Filed under spring framework

<원문>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
Posted
Filed under spring framework
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

blog.visualp.com

blog.visualp.com

blog.visualp.com

Posted
Filed under spring framework
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

blog.visualp.com

Posted
Filed under spring framework

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