代码之家  ›  专栏  ›  技术社区  ›  ALovedSon

Spring JDBCTemplate是否清理URL?

  •  0
  • ALovedSon  · 技术社区  · 6 年前

    我在构建spring boot api的过程中遇到了一个小问题,我希望更熟悉spring boot幕后工作原理的人能够给我一些建议。

    我在一个控制器中有一个@responsebody标记的方法,该方法生成一个db查询,并将结果封送到json,如下所示:

        @RequestMapping(value = "/oneLibInfo",method = RequestMethod.GET)
        @ResponseBody
        List<LibInfo> getOneLibInfo(@RequestParam(required = true,value = "NUC")String NUC){
    
        List<LibInfo> libInfos = jdbcTemplate.query(
                "select o.organisation_id, o.name, a.alias, i.service_id, i.library_system_id, i.web_catalog_baseurl, ls.LIBRARY_SYSTEM_NAME,ls.LIBRARY_SYSTEM_VENDOR,ls.QUERY_PARAM_ISBN,ls.QUERY_PARAM_TITLE,ls.QUERY_PARAM_ISBN,ls.QUERY_PARAM_AUTHOR_TITLE\n" +
                        "from ALG1.LIBRARY_SYSTEM ls\n" +
                        "  INNER JOIN ALG1.ALG_INFORMATION i on i.LIBRARY_SYSTEM_ID = ls.LIBRARY_SYSTEM_ID\n" +
                        "  inner join dir.service s on s.service_id = i.service_id\n" +
                        "  inner join dir.organisation o on o.organisation_id = s.organisation_id\n" +
                        "  inner join dir.organisation_alias a on a.organisation_id = o.organisation_id\n" +
                        "where a.alias in (?)\n" +
                        "      and a.alias_type = 'Union catalogue symbol'",
                new Object[]{NUC}
                ,new BeanPropertyRowMapper<>(LibInfo.class,false)
        );
        return libInfos;
        }
    

    在外部运行到应用程序时,查询工作正常。

    它在应用程序中也可以正常工作,但有一列无法返回:webcataloguebaseurl。

    这个列,顾名思义包含一个url,返回未定义的。 我一辈子都搞不懂为什么。以前有人遇到过这样的问题吗?

    P.S:用于行映射的域类:

    package au.gov.nla.deeplinkhelper.domain;
    

    公共类libinfo{

    public LibInfo() {
    }
    
    
    public LibInfo(String name, String alias, String serviceId, String librarySystemId, String webCatalogueBaseurl, String librarySystemName, String librarySystemVendor, String queryParamIsbn, String queryParamTitle, String queryParamIssn, String queryParamAuthorTitle) {
        this.name = name;
        this.alias = alias;
        this.serviceId = serviceId;
        this.librarySystemId = librarySystemId;
        this.webCatalogueBaseurl = webCatalogueBaseurl;
        this.librarySystemName = librarySystemName;
        this.librarySystemVendor = librarySystemVendor;
        this.queryParamIsbn = queryParamIsbn;
        this.queryParamTitle = queryParamTitle;
        this.queryParamIssn = queryParamIssn;
        this.queryParamAuthorTitle = queryParamAuthorTitle;
    }
    
    String name;
    String alias;
    String serviceId;
    String librarySystemId;
    String webCatalogueBaseurl;
    String librarySystemName;
    String librarySystemVendor;
    String queryParamIsbn;
    String queryParamTitle;
    String queryParamIssn;
    String queryParamAuthorTitle;
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String getAlias() {
        return alias;
    }
    
    public void setAlias(String alias) {
        this.alias = alias;
    }
    
    public String getServiceId() {
        return serviceId;
    }
    
    public void setServiceId(String serviceId) {
        this.serviceId = serviceId;
    }
    
    public String getLibrarySystemId() {
        return librarySystemId;
    }
    
    public void setLibrarySystemId(String librarySystemId) {
        this.librarySystemId = librarySystemId;
    }
    
    public String getWebCatalogueBaseurl() {
        return webCatalogueBaseurl;
    }
    
    public void setWebCatalogueBaseurl(String webCatalogueBaseurl) {
        this.webCatalogueBaseurl = webCatalogueBaseurl;
    }
    
    public String getLibrarySystemName() {
        return librarySystemName;
    }
    
    public void setLibrarySystemName(String librarySystemName) {
        this.librarySystemName = librarySystemName;
    }
    
    public String getLibrarySystemVendor() {
        return librarySystemVendor;
    }
    
    public void setLibrarySystemVendor(String librarySystemVendor) {
        this.librarySystemVendor = librarySystemVendor;
    }
    
    public String getQueryParamIsbn() {
        return queryParamIsbn;
    }
    
    public void setQueryParamIsbn(String queryParamIsbn) {
        this.queryParamIsbn = queryParamIsbn;
    }
    
    public String getQueryParamTitle() {
        return queryParamTitle;
    }
    
    public void setQueryParamTitle(String queryParamTitle) {
        this.queryParamTitle = queryParamTitle;
    }
    
    public String getQueryParamIssn() {
        return queryParamIssn;
    }
    
    public void setQueryParamIssn(String queryParamIssn) {
        this.queryParamIssn = queryParamIssn;
    }
    
    public String getQueryParamAuthorTitle() {
        return queryParamAuthorTitle;
    }
    
    public void setQueryParamAuthorTitle(String queryParamAuthorTitle) {
        this.queryParamAuthorTitle = queryParamAuthorTitle;
    }
    

    }

    这是从rest控制器返回的示例输出:

    data
    :
    Array(1)
    0
    :
    alias
    :
    "NSCU:L"
    librarySystemId
    :
    "1194"
    librarySystemName
    :
    "Alma-test3 NSCU"
    librarySystemVendor
    :
    "Ex libris"
    name
    :
    "University Library Lismore"
    queryParamAuthorTitle
    :
    null
    queryParamIsbn
    :
    "$$ISBN$$&tab=Everything&search_scope=MyInst_and_CI&vid=61SCU_INST:61SCU&offset=0"
    queryParamIssn
    :
    null
    queryParamTitle
    :
    "$$TITLE$$&tab=Everything&search_scope=MyInst_and_CI&vid=61SCU_INST:61SCU&offset=0"
    serviceId
    :
    "4216"
    webCatalogueBaseurl
    :
    null
    

    最后一项是问题一。

    这是在用 弹簧靴2.01 用一个 五险合一系统 是的。

    只有包含url的列似乎会冒泡出来。

    1 回复  |  直到 6 年前
        1
  •  1
  •   Strelok    6 年前

    数据库列名为 web_catalog_baseurl 但是你的bean属性被命名为 webCatalogueBaseurl 是的。 catalog catalogue 所以对于bean映射器来说,这是不一样的。

    将bean属性重命名为 webCatalogBaseurl

    private String webCatalogBaseurl;
    
    public String getWebCatalogBaseurl() {
        return webCatalogBaseurl;
    }
    
    public void setWebCatalogBaseurl(String webCatalogBaseurl) {
        this.webCatalogBaseurl = webCatalogBaseurl;
    }