0

私はいくつかのjspページmanage.jspとその中にフォームを持っています:

<form method="POST" action="./manage.form">
    <div style=" float: left;">
        <textarea id="errors" name="errors">${ignoredExceptions}</textarea>
    </div>

    <div id="successOrErrorSave"></div>

    <div style="clear: both;">
        <input type="submit" id="saveIgnoredErrors" style="margin-left: auto; margin-top: 10px;" value="<spring:message code="errorlogging.ignredExceptions.save" />"/>
    </div>
 </form>

そして、私はいくつかのコントローラー ManageController を持っています:

/**
 * The main controller.
 */
@Controller
public class ManageController {

    protected final Log log = LogFactory.getLog(getClass());


    @RequestMapping(value = "/module/manage", method = RequestMethod.GET)
    public void showForm(ModelMap model) {
        GlobalProperty glProp = Context.getAdministrationService().getGlobalPropertyObject(
            Constants.GP_IGNORED_EXCEPTION);
        if (glProp != null) {
            model.addAttribute("ignoredExceptions", glProp.getPropertyValue());
        } else {
            model.addAttribute("ignoredExceptions", "");
        }
    }


    @RequestMapping(value = "module/manage", method = RequestMethod.POST)
    public String processSubmit(@ModelAttribute(value = "ignoredExceptions") String ignoredExceprions, BindingResult result,
                                SessionStatus status) {
        boolean successSave = false;
        GlobalProperty glProp = Context.getAdministrationService().getGlobalPropertyObject(
            ErrorLoggingConstants.ERRROR_LOGGING_GP_IGNORED_EXCEPTION);
        if (glProp != null) {
            glProp.setPropertyValue(ignoredExceprions);
            GlobalProperty saved = Context.getAdministrationService().saveGlobalProperty(glProp);
            System.out.println(saved.getPropertyValue());
                        if (saved != null && saved.getPropertyValue().equals(ignoredExceprions)) {
                successSave = true;
            }
        }
                status.setComplete();
        return "module/manage";
    }
}

テキストエリアで管理ページを開くと、現在のignoredExceptionsが表示されます。ユーザーが入力したignoredExceptionsの新しい値を保存する必要があります。その後、同じ管理ページにリダイレクトすると、ignoredExceptionsの新しい値が表示されます。これどうやってするの?

4

1 に答える 1

0

変更されたignoredExceptionsの値は、フォームのerrorsという名前のテキストエリアフィールドに関連付けられているため、エラーの値をリクエストから、またはRequestParameterとして読み取ることができます

@RequestMapping(value = "module/manage", method = RequestMethod.POST)
public String processSubmit(@RequestParam(value = "errors", required = false) String   ignoredExceprions, BindingResult result,
                            SessionStatus status) {
    boolean successSave = false;
    GlobalProperty glProp = Context.getAdministrationService().getGlobalPropertyObject(
        ErrorLoggingConstants.ERRROR_LOGGING_GP_IGNORED_EXCEPTION);
    if (glProp != null) {
        glProp.setPropertyValue(ignoredExceprions);
        GlobalProperty saved = Context.getAdministrationService().saveGlobalProperty(glProp);
        System.out.println(saved.getPropertyValue());
                    if (saved != null && saved.getPropertyValue().equals(ignoredExceprions)) {
            successSave = true;
        }
    }
            status.setComplete();
    return "module/manage";
}

}

于 2012-07-31T18:20:40.283 に答える