i learning basics of mvc based on servlet , .jsp; when tried have simple test, intellij gave me warning on items="${}" of such:"this inspection reports possible el problems, such unresolved references , invalid el locations";
i checked servlet configuration in web.xml; checked path of .jsp file in root, doesn't work;
here's code:
--testview.jsp
<%@ page contenttype="text/html;charset=utf-8" language="java" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <html> <head> <title>test view</title> </head> <body> <c:foreach var="templist" items = "${mystringlist}"> ${templist} <br/> </c:foreach> </body>
--testservlet.java
import javax.servlet.requestdispatcher; import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import javax.servlet.http.httpservletresponse; import java.io.ioexception; @webservlet(name = "testservlet") public class testservlet extends httpservlet { protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { } protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { string[] list = {"aaa","bbb","ccc","ddd","eee"}; request.setattribute("mystringlist", list); requestdispatcher dispatcher = request.getrequestdispatcher("/testview.jsp"); dispatcher.forward(request,response); } }
--web.xml
<?xml version="1.0" encoding="utf-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> <servlet> <servlet-name>testservlet</servlet-name> <servlet-class>com.gpwz.labexcercise.testservlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>testservlet</servlet-name> <url-pattern>/testservlet</url-pattern> </servlet-mapping>
any advice? searched lot, none of them can solve issue...
Comments
Post a Comment