小编Fil*_*nov的帖子

Jackson JSON和Hibernate JPA问题的无限递归

在尝试将具有双向关联的JPA对象转换为JSON时,我不断获取

org.codehaus.jackson.map.JsonMappingException: Infinite recursion (StackOverflowError)
Run Code Online (Sandbox Code Playgroud)

我找到的只是这个线程,基本上建议避免双向关联.有没有人对这个春天的bug有一个解决方法?

------编辑2010-07-24 16:26:22 -------

Codesnippets:

业务对象1:

@Entity
@Table(name = "ta_trainee", uniqueConstraints = {@UniqueConstraint(columnNames = {"id"})})
public class Trainee extends BusinessObject {

    @Id
    @GeneratedValue(strategy = GenerationType.TABLE)
    @Column(name = "id", nullable = false)
    private Integer id;

    @Column(name = "name", nullable = true)
    private String name;

    @Column(name = "surname", nullable = true)
    private String surname;

    @OneToMany(mappedBy = "trainee", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
    @Column(nullable = true)
    private Set<BodyStat> bodyStats;

    @OneToMany(mappedBy = "trainee", fetch = FetchType.EAGER, …
Run Code Online (Sandbox Code Playgroud)

java orm json spring-mvc jackson

375
推荐指数
15
解决办法
26万
查看次数

用于2脚(客户端凭据)OAuth2服务器的Spring-security上下文设置

如果我想为一个客户端保护REST服务器,那么spring-security OAuth2的最小设置是什么?我不想使用任何不必要的设置或实现任何不必要的bean.对于spring-security + OAuth2,可能已经有一个"简单"的教程/示例了吗?(虽然我试图避免过于充满希望)

我当前的工作设置(使用来自sparklr上下文的副本+过去+ wtf)感觉太多了:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
       xmlns:sec="http://www.springframework.org/schema/security"
       xsi:schemaLocation="http://www.springframework.org/schema/security/oauth2
                           http://www.springframework.org/schema/security/spring-security-oauth2-1.0.xsd
                           http://www.springframework.org/schema/security
                           http://www.springframework.org/schema/security/spring-security-3.1.xsd
                           http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">

    <oauth:authorization-server client-details-service-ref="clientDetails" token-services-ref="tokenServices">
        <oauth:client-credentials />
    </oauth:authorization-server>

    <sec:authentication-manager alias="clientAuthenticationManager">
        <sec:authentication-provider user-service-ref="clientDetailsUserService" />
    </sec:authentication-manager>

    <http pattern="/oauth/token" create-session="stateless"
            authentication-manager-ref="clientAuthenticationManager"
            xmlns="http://www.springframework.org/schema/security">
        <intercept-url pattern="/oauth/token" access="IS_AUTHENTICATED_FULLY" />
        <anonymous enabled="false" />
        <http-basic entry-point-ref="clientAuthenticationEntryPoint" />

        <!-- include this only if you need to authenticate clients via request parameters -->
        <custom-filter ref="clientCredentialsTokenEndpointFilter" before="BASIC_AUTH_FILTER" />
        <access-denied-handler ref="oauthAccessDeniedHandler" />
    </http>

    <oauth:resource-server id="resourceServerFilter"
            resource-id="rest_server" token-services-ref="tokenServices" />

    <oauth:client-details-service id="clientDetails">
        <oauth:client client-id="the_client" authorized-grant-types="client_credentials" 
                authorities="ROLE_RESTREAD" secret="1234567890" />
    </oauth:client-details-service> …
Run Code Online (Sandbox Code Playgroud)

java spring spring-security oauth-2.0

31
推荐指数
1
解决办法
2万
查看次数

如何在Spring Web MVC中使用Ajax JQuery

我在我的应用程序中使用Spring Web MVC.

我的JSP视图中有一个下拉列表,来自下面的请求 savegroup.htm

<bean name="/savegroup.htm" class="com.sufalam.mailserver.presentation.web.GroupSaveController">
    <property name="sessionForm" value="true"/>
    <property name="commandName" value="Group"/>
    <property name="commandClass" value="com.sufalam.mailserver.presentation.bean.GroupViewBean"/>
    <property name="formView" value="common"/>
    <property name="successView" value="managegroup.htm"/>
    <property name="userSecurityProcessor" ref="IUserSecurityProcessor"/>
    <property name="domainsSecurityProcessor" ref="IDomainsSecurityProcessor"/>
    <property name="forwardingsSecurityProcessor" ref="IForwardingsSecurityProcessor"/>
</bean>
Run Code Online (Sandbox Code Playgroud)

JSP页面有:

<form:form name="groupSaveForm" action="savegroup.htm" commandName="Group" method="POST">
    Group Name :
    <form:input path="source"/><br><br>
    Domain List :
    <form:select id="domains" onchange="javascript:getUser();" path="domainsList" multiple="false" size="1">
        <form:option value="-" label="--Select--"/>
        <form:options items="${domainsList}" itemValue="domain" itemLabel="domain"/>
    </form:select>
</form:form>
Run Code Online (Sandbox Code Playgroud)

现在我的要求是,在我的下拉列表的更改事件中,我想从服务器获取相关用户并在某个列表框中显示该用户列表.

为此我怎么能使用jQuery AJAX调用?

我应该在哪里处理接收请求和获取相关用户的服务器端代码?

如何在我的JSP中显示即将到来的用户组?

java ajax jquery jsp spring-mvc

23
推荐指数
1
解决办法
4万
查看次数

为什么 webpack 默认包含一个 Buffer polyfill?

Webpack 文档说Buffer默认情况下包含一个 polyfill ( https://webpack.js.org/configuration/node/#node-buffer )。

  1. 为什么会这样?

  2. 对于不需要使用的人来说,它是否会使捆绑包更大Buffer

webpack

6
推荐指数
0
解决办法
2277
查看次数

在Thymeleaf中使用'select'标签和实体

我正在创建一个带有select标签的表单,如下所示:

<form th:object="${version}" method="post" class="form-horizontal">
    ...
    <div class="control-group" th:classappend="${#fields.hasErrors('product')} ? 'error'">
        <label class="control-label" for="product" th:text="#{version.product}">Product</label>
        <div class="controls">
            <select id="product" th:field="*{product}">
                <option value="" th:text="#{common.select.prompt}"></option>
                <option th:each="p : ${productList}" th:value="${p.id}"  th:text="${p.name}"></option>
            </select>
            <span class="help-inline" th:errors="*{product}"></span>
        </div>
    </div>
    ...
</form>
Run Code Online (Sandbox Code Playgroud)

DomainClassConverter当我提交表单时,Spring Data JPA有助于将所选内容自动转换id为实体Product的类.该product也应该是不为空(我用@NotNullproduct领域Version类.

我遇到的问题 - 当我回来编辑数据时,Product没有选中.

如果我修改了select这个(th:fieldth:errors):<-- p.s. is not a sad smile

<select id="product" th:field="*{product.id}">
    <option value="" th:text="#{common.select.prompt}"></option> …
Run Code Online (Sandbox Code Playgroud)

java spring-mvc thymeleaf

5
推荐指数
1
解决办法
2万
查看次数

JavaScript正则表达式(页面范围验证)

昨天我有一个任务是在用户可以输入他想要下载的页面范围的字段上实现验证.

在阅读了一些教程之后,我创建了这样的模式,在我看来应该可行,但它没有:(

你能否给我一个提示,说明错误在哪里,或者以更好的方式完成.

<script type="text/javascript">
var patt1=new RegExp("^(\s*\d+\s*\-\s*\d+\s*,?|\s*\d+\s*,?)+$");
document.write(patt1.test("1, 2, 3-5, 6, 8, 10-12"));
</script>
Run Code Online (Sandbox Code Playgroud)

PS你可以在这里测试一下:http://www.w3schools.com/js/tryit.asp?filename = tryjs_regexp_test

更多例子:

  • 1场比赛
  • 1-2比赛
  • -2不匹配
  • 1,2,3,4,5匹配
  • 1 2,3不匹配
  • 1-2-2不匹配

等......就像在MS Office或Adobe PDF Reader中一样

javascript regex

3
推荐指数
2
解决办法
2677
查看次数

Bootstrap Modal无法正常工作

我有一个简单的按钮,使用bootstrap的模态,就像一个弹出div.我无法让它发挥作用.当我点击按钮时,没有任何反应.我用的是firefox.我可能忘记了简单的事情,但我找不到问题.

        <!DOCTYPE html>
        <html>
          <head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type='text/javascript' src='http://twitter.github.com/bootstrap/1.4.0/bootstrap-modal.js'></script>
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css">

     </head>
     <body>

      <a class="btn" data-controls-modal="my-modal" data-backdrop="static" id='mod'>Launch Modal</a>

     </body>
   </html>
Run Code Online (Sandbox Code Playgroud)

html modal-dialog twitter-bootstrap

3
推荐指数
1
解决办法
2万
查看次数