My English teacher used to say that a poem can have deep meaning beyond that
This is a very good quesiton, and a very hard one. My own view is that your teacher was right, but that there are limits to how far the point can be pushed. Poetry, of course, is characterized by the extensive use of metaphor and other figures of speech. So just consider metaphor. Can a particular metaphor mean something beyond what its author intended? I find the question to be somewhat ill conceived, because it seems to suppose that the author of the metaphor had some paticular interpretation of it in mind, and that's not at all obvious. In my limited experience writing poetry, that certainly hasn't been my experience; and, as is often pointed out, metaphor comes in for pretty heavy use in philosophy itself. (Thus Quine, more or less: The lore of our fathers is a dull gray cloth, black with fact and white with convention, but nowhere quite black or quite white.) It's not that there's something very specific I want to say and could just as well say prefectly literally. Rather, the metaphor itself just seems right somehow, and I know, of course, that my reader will have to work with the metaphor herself. In that sense, it seems to me as if I essentially birth the metaphor which then assumes a life of its own. (Aha! a metaphor!) Now, of course, the fact that there needn't be one "correct" way to interpret the metaphor doesn't mean that anything goes, and if someone tries to tell me that Pablo Neruda's "Do Not Go Off, Even For a Day" is actually about the horrors of Iraq, then, well, as I said, there are limits.
As for Locke, few nowadays would endorse this kind of view.