首页 \ 问答 \ spring jvc model value with jsp tags(spring mvc model value with jsp tags)

spring jvc model value with jsp tags(spring mvc model value with jsp tags)

这就是我所拥有的:我在jsp页面中使用JTable( http://www.jtable.org/ )以及spring mvc模型。 我也有设置本地化,所有这些工作正常。 下面我有我的部分代码,添加了我认为相关的内容,因为我不确定...请在我得到一些输入后立即问我(将在周一回答,因为在周末,我可以通过电脑访问) 。

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/views/"/>
    <property name="suffix" value=".jsp"/>
</bean>

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basename" value="classpath:i18n/messages"/>
    <property name="defaultEncoding" value="UTF-8"/>
</bean>

<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
    <property name="paramName" value="lang"/>
</bean>

<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
    <property name="defaultLocale" value="en_US"/>
</bean>

这是我需要做的:我需要创建一个jtable,其中字段,操作等来自服务器,以便它们是动态的(检查动态创建由其他用户制作的jQuery-jTable的多级Javascript对象 )。 在我的情况下,myobj将来自服务器作为字符串,即

 @RequestMapping(value = "/locales", method = RequestMethod.GET)


public ModelAndView testList(ModelAndView mv, final HttpServletRequest request) {
    mv.setViewName("list");
    mv.addObject("model",
     "{\n" +
       "                    title: '<spring:message code=\"table.users.users\"/>',\n" +
        ....
       "                    fields: {\n" +
       "                        ID: {\n" +
       "                            key: true,\n" +
       "                            list: false,\n" +
       "                            create: false,\n" +
       "                            edit: false\n" +
       "                        },\n" +
       "                        Name: {\n" +
       "                            title: '<spring:message code=\"table.name\"/>',\n" +
       "                            width: '15%',\n" +
      ...

您在控制器模型中传递的上述文本将动态创建(使用速度引擎,动态数据......)

list.jsp如下:

    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<tags:template>
    <jsp:body>
         <script>
            $(document).ready(function() {
                $('#ListContainer').jtable(${model});
                $('#ListContainer').jtable('load');
            });
        </script>
            <div id="ListContainer" style="width:99%;"></div>
    </jsp:body>
</tags:template>

我的问题是,虽然我在我的网站设置本地化等等,但是当这些标记位于控制器返回模型的内容中时,它们不会被渲染。 有没有办法对Controller或InternalResourceViewResolver说出解决模型的值,好像它是一个jsp?

我希望我能清楚地解决问题并提供回复我所需的一切,如果没有,请随意提问。 我担心,因为我仍然倾向于我没有清楚在我的脑海里如何所有这些绑定我唯一知道的是我需要有一个动态/通用jtable列表完全本地化列表。


Here is what i have: I am using JTable (http://www.jtable.org/) inside jsp pages, along with spring mvc model. I also have setup localization, all these work fine. Below i have part of my code, added what i consider as relevant as i am not sure... Please ask me as soon as you get some input for me (will answer on monday as in weekend i doupt i can have pc access).

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/views/"/>
    <property name="suffix" value=".jsp"/>
</bean>

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basename" value="classpath:i18n/messages"/>
    <property name="defaultEncoding" value="UTF-8"/>
</bean>

<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
    <property name="paramName" value="lang"/>
</bean>

<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
    <property name="defaultLocale" value="en_US"/>
</bean>

Here is what i need to do: I need to create a jtable where fields, actions,etc come from server so that these are dynamic (check Dynamic creation of multilevel Javascript object for jQuery-jTable made from other user). In my case myobj will come from server as a string, i.e.

 @RequestMapping(value = "/locales", method = RequestMethod.GET)


public ModelAndView testList(ModelAndView mv, final HttpServletRequest request) {
    mv.setViewName("list");
    mv.addObject("model",
     "{\n" +
       "                    title: '<spring:message code=\"table.users.users\"/>',\n" +
        ....
       "                    fields: {\n" +
       "                        ID: {\n" +
       "                            key: true,\n" +
       "                            list: false,\n" +
       "                            create: false,\n" +
       "                            edit: false\n" +
       "                        },\n" +
       "                        Name: {\n" +
       "                            title: '<spring:message code=\"table.name\"/>',\n" +
       "                            width: '15%',\n" +
      ...

This text you see above passed in the model of the controller will be created dynamically (using velocity engine,dynamic data,...)

list.jsp is as follows:

    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<tags:template>
    <jsp:body>
         <script>
            $(document).ready(function() {
                $('#ListContainer').jtable(${model});
                $('#ListContainer').jtable('load');
            });
        </script>
            <div id="ListContainer" style="width:99%;"></div>
    </jsp:body>
</tags:template>

My problem is that although i have in my site setup localization et all, the tags i.e. ' are not rendered when these are inside the content of the controller's returned model. Is there a way to say to the Controller or the InternalResourceViewResolver to resolve the model's value as if it was a jsp?

I hope i made my problem clear and gave all that is needed to respond to me, if not please feel free to ask. I am afraid since i am still leaning i do not have either clear in my mind how all these bind together the only thing i know is that i need to have a dynamic/generic jtable list fully localized list.


原文:https://stackoverflow.com/questions/24329160
更新时间:2024-04-23 12:04

最满意答案

这些设置不会影响任何事情。 它们是标准化的logstash字段,可用于轻松报告源自多个源的日志。

它们只是一个logstash约定而不是弹性搜索约定。


Those settings do not affect anything. They are standardised logstash fields which are used so you can easily report on logs originating from multiple sources.

They are just a logstash convention and not an elasticsearch convention.

相关问答

更多
  • 您正在使用的文本查询前一段时间已被弃用(有效重命名),以支持匹配查询 。 匹配查询支持单个字段,但您可以使用multi_match查询 ,该查询支持非常相同的选项并允许在多个字段上进行搜索。 这是一个应该对你有帮助的例子: { "query" : { "multi_match" : { "fields" : ["title", "subtitle"], "query" : "trying out ela", "t ...
  • 根据Mozilla页面: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API/Using_IndexedDB “由于规范仍在不断发展,IndexedDB的当前实现隐藏在浏览器前缀之下。浏览器供应商可能会有不同的标准IndexedDB API实现,直到规范得到巩固。但是一旦达到标准的共识,供应商就会在没有前缀的情况下实现它。实际上一些实现已经删除了前缀:Internet Explorer 10,Firefox 16,Chrome 24. ...
  • 这些设置不会影响任何事情。 它们是标准化的logstash字段,可用于轻松报告源自多个源的日志。 它们只是一个logstash约定而不是弹性搜索约定。 Those settings do not affect anything. They are standardised logstash fields which are used so you can easily report on logs originating from multiple sources. They are just a logs ...
  • 您可以使用任何logstash过滤器删除字段 - 当过滤器成功时,它将删除该字段。 使用mutate对我来说很有意义: filter { mutate { remove_field => [ "file" ] } } 也就是说,这些领域中的大多数都非常有用,实际上不应该删除。 You can remove fields using really any logstash filter - when the filter succeeds, it will remove th ...
  • SQL和Elasticsearch之间的关键区别在于,默认情况下, 在索引时分析字符串字段,您可以控制使用分析程序分析字符串的方式。 默认分析器标准分析器将从输入生成标记并将它们存储在倒排索引中。 您可以使用Analyze API查看为给定输入生成的令牌: curl -XPOST "http://localhost:9200/_analyze?analyzer=standard" -d' { text : "3-Series" }' 产生输出 { "tokens": [ { " ...
  • 根据Elasticsearch文档: “术语聚合不支持从同一文档中的多个字段收集术语。原因是术语字段本身不收集字符串术语值,而是使用全局序数来生成所有唯一值的列表。全球序数导致重要的性能提升,这在多个领域是不可能的。 您可以使用两种方法在多个字段中执行术语聚合: 脚本使用脚本从多个字段中检索术语。 这会禁用全局序数优化,并且比从单个字段中收集术语要慢,但它使您可以灵活地在搜索时实现此选项。 copy_to字段如果您提前知道要从两个或多个字段中收集术语,请在映射中使用copy_to在索引时创建一个包含两个字段 ...
  • 我不知道为什么你的工作没有用,但我过去使用bool过滤器取得了巨大的成功。 should选项基本上是一个or确保至少有一个是真的。 如果它仍然不起作用,试一试并评论我的答案。 另外仔细检查我正确复制了你的查询条款:) { "filtered" : { "query" : { "match_phrase_prefix": { "display_name": "SearchQuery" } } ...
  • Access SQL不支持CONCATENATE() 。 通常,您将使用&进行连接。 但是我不认为你需要为你的连接的ON条件连接任何东西。 只需使用Mid()忽略前2个字符...... ON Mid(a.ID, 3) = b.ID 这应该有效,但随着时间的推移,表格可能变得不可接受。 通过在每次导入后立即“清理” a.ID值,您应该获得更好的性能... UPDATE a SET ID = Mid(ID, 3) WHERE ID ALike '31%'; 那么你的SELECT查询的连接可以使用更简单,更快 ...
  • 仅在尝试获取存储的字段时使用字段。 默认情况下,您应该使用源获取字段。 使用以下代码示例,我将尝试解释它。 PUT documents { "settings": { "number_of_replicas": 0, "number_of_shards": 1 }, "mappings": { "document": { "properties": { "title": { "type": "text", ...
  • 如果你没有一个特定的查询应该匹配嵌套的字段,你可以这样做: GET /index/_search { "size": 10, "_source": ["nested_fields.id", "nested_fields.name"] } 如果您还有一个nested查询并且想要返回匹配的嵌套文档,则可以这样做(使用inner_hits ): { "query": { "nested": { "path": "nested_fields", "query": {"m ...

相关文章

更多

最新问答

更多
  • CSS修复容器和溢出元素(CSS Fix container and overflow elements)
  • SQL多个连接在与where子句相同的表上(SQL Multiple Joins on same table with where clause)
  • nginx 80端口反向代理多个域名,怎样隐藏端口的
  • xcode提醒样式,swift 3(xcode alert style, swift 3)
  • 在Chrome控制台中调试JavaScript(debugging javascript in Chrome console)
  • Javascript - 试图围绕自定义事件(Javascript - Trying to wrap my head around custom events)
  • 边栏链接不可点击(Sidebar links aren't clickable)
  • 使用recpatcha gem时如何显示其他表单错误?(How do I display other form errors when using the recpatcha gem?)
  • boost.python避免两次注册内部类,但仍然在python中公开(boost.python Avoid registering inner class twice but still expose in python)
  • Android 现在软件很少吗?以后会多起来吗
  • 如何在ActiveAdmin 0.5.0中为资源全局指定预先加载?(How to specify eager loading globally for a resource in ActiveAdmin 0.5.0?)
  • matlab代码为黄金比例持续分数(matlab code for golden ratio continued fraction)
  • Android浏览器触摸事件位置(Android browser touch event location)
  • 将cURL输出分配给Bash中的变量(Assign output to variable in Bash)
  • 我如何在MVC视图上没有时间获取当前日期(how i can get current date without time on MVC view)
  • sql连接函数(sql join of function)
  • 为什么在Xamarin Media插件中使用ImageSource.FromStream而不是FromFile?(Why use ImageSource.FromStream instead of FromFile in Xamarin Media plugin?)
  • 这段代码是否真的可以防止SQL注入?(Will this code actually work against SQL-injection? [duplicate])
  • 信阳方远计算机学校大专证被国家认可么
  • React / Rails AJAX POST请求返回404(React/Rails AJAX POST request returns 404)
  • Android与php服务器交互(Android interact with php server)
  • 自动刷新QTableWidget可能吗?(Refresh QTableWidget automatically possible?)
  • JVM / Compiler优化对象的未使用属性(optimization of unused properties of object by JVM / Compiler)
  • 插入表格时,乌克兰字符会更改为问号(Ukrainian character change to question mark when insert to table)
  • 在头文件中包含异常类(Including an exception class in a header file)
  • 完成c#中的执行后关闭sqlcmd(Close sqlcmd after finishing executing in c#)
  • 使用软导航栏正确检测屏幕尺寸(Detecting screensize correctly with soft navigation bar)
  • Typescript:从输入更新值(Typescript : update value from input)
  • 如何在执行某些行后仅在断点处停止?(How to only stop at a breakpoint after some line was executed?)
  • 以未定义的元素在JSON中循环(loop in JSON with undefined elements)