为每年的每个循环反转JSTL(使用下拉列表)

时间:2016-09-21 03:05:29

标签: java jsp foreach jstl

我想创建一个以当前年份开头的下拉菜单,或者至少从2016年开始到1900年结束

我只有正确的割草代码,但工作不正常。

$ npm start

\> angular-quickstart@1.0.0 start /Users/kimnicolemontano/quickstart
\> tsc && concurrently "tsc -w" "lite-server" 
     Did not detect a `bs-config.json` or `bs-config.js` override file. Using lite-server defaults...
     ** browser-sync config **
     { injectChanges: false,
     files: [ './**/*.{html,htm,css,js}' ],
     watchOptions: { ignored: 'node_modules' },
     server: { baseDir: './', middleware: [ [Function], [Function] ] } }
     dyld: lazy symbol binding failed: Symbol not found: _node_module_register
     Referenced from: /Users/username/quickstart/node_modules/fsevents/lib/binding/Release/node-v48-darwin-x64/fse.node
     Expected in: flat namespace

     dyld: Symbol not found: _node_module_register
     Referenced from: /Users/username/quickstart/node_modules/fsevents/lib/binding/Release/node-v48-darwin-x64/fse.node
     Expected in: flat namespace

     10:53:50 AM - Compilation complete. Watching for file changes.

1 个答案:

答案 0 :(得分:2)

试试这个。

<select id="year" name="year">
            <c:forEach begin="0" end="116" var="val">
                <c:set var="decr" value="${2016 - val}"/>
                <option value="${decr}" ${birthYear == decr ? "selected='selected'": ''}>${decr}</option>
            </c:forEach>
</select>